Last updated:
0 purchases
flutter mock web server
MockWebServer Plugin for Flutter #
A plugin that provides a mock web server to test HTTP requests and responses in Dart.
Getting Started
Import the package: import 'package:mock_web_server/mock_web_server.dart';
Create an instance of MockWebServer: var server = MockWebServer();
Start the server: await server.start();
Enqueue HTTP responses to the response queue using enqueue().
Dispatch HTTP requests using dispatchRequest() and verify the responses received.
Example
var server = MockWebServer();
await server.start();
server.enqueue(httpCode: 200, body: '{"name": "John"}');
var response = await http.get(server.url);
expect(response.statusCode, equals(200));
expect(response.body, equals('{"name": "John"}'));
server.verifyRequestCount(1);
server.verifyNoMoreRequests();
await server.shutdown();
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.