mock_request 1.0.2

  • Installing
  • Versions
  • 51


Pub build status

Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. This makes it possible to test server-side Dart applications without having to ever bind to a port.

This package was originally designed to testing Angel applications smoother, but works with any Dart-based server. :)


var rq = new MockHttpRequest('GET', Uri.parse('/foo'));
await rq.close();
await app.handleRequest(rq); // Run within your server-side application
var rs = rq.response;
expect(rs.statusCode, equals(200));
expect(await rs.transform(UTF8.decoder).join(),
    equals(JSON.encode('Hello, world!')));

More examples can be found in the included tests.

1. Depend on it

Add this to your package's pubspec.yaml file:

  mock_request: "^1.0.2"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:mock_request/mock_request.dart';
Version Uploaded Documentation Archive
1.0.2 Jul 2, 2017 Go to the documentation of mock_request 1.0.2 Download mock_request 1.0.2 archive
1.0.1 Jun 12, 2017 Go to the documentation of mock_request 1.0.1 Download mock_request 1.0.1 archive
1.0.0 Mar 25, 2017 Go to the documentation of mock_request 1.0.0 Download mock_request 1.0.0 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6


Describes how popular the package is relative to other packages. [more]
40 / 100
Code health derived from static analysis. [more]
54 / 100
Reflects how tidy and up-to-date the package is. [more]
73 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Primary library: package:mock_request/mock_request.dart with components: io.


  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 14 errors 1 hint.

    Strong-mode analysis of lib/src/request.dart failed with the following error:

    line: 9 col: 7
    Missing concrete implementations of 'Stream.cast' and 'Stream.retype'.

    Strong-mode analysis of lib/src/session.dart failed with the following error:

    line: 3 col: 7
    Missing concrete implementations of 'Map.addEntries', 'Map.cast', '', 'Map.removeWhere' and 4 more.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use mock_request.dart.


Package Constraint Resolved Available
Direct dependencies
charcode >=1.0.0 <2.0.0 1.1.1
Dev dependencies
angel_framework >=1.0.0-dev <2.0.0
http >=0.11.3 <0.12.0
test >=0.12.0 <0.13.0