flutter_mock_web_server 1.0.0 copy "flutter_mock_web_server: ^1.0.0" to clipboard
flutter_mock_web_server: ^1.0.0 copied to clipboard

A null-safe mock_web_server package for Dart and Flutter

MockWebServer Plugin for Flutter #

A plugin that provides a mock web server to test HTTP requests and responses in Dart.

Getting Started

  1. Import the package: import 'package:mock_web_server/mock_web_server.dart';
  2. Create an instance of MockWebServer: var server = MockWebServer();
  3. Start the server: await server.start();
  4. Enqueue HTTP responses to the response queue using enqueue().
  5. 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();
3
likes
130
pub points
59%
popularity

Publisher

unverified uploader

A null-safe mock_web_server package for Dart and Flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

http, stack_trace

More

Packages that depend on flutter_mock_web_server