mockzilla 1.0.2 copy "mockzilla: ^1.0.2" to clipboard
mockzilla: ^1.0.2 copied to clipboard

A solution for configuring and running a local HTTP server as part of a Flutter app.

A Flutter plugin for running and configuring a local, mock HTTP server that allows your mobile app to simulate calls to a REST API.

Full documentation available here!

Why use Mockzilla? #

✅ Compile safe mock endpoint definitions.

✅ HTTP client agnostic.

✅ Works completely offline.

✅ Entirely self-contained in your application's codebase.

To hit the ground running #

⚠️ Warning: Mockzilla is a development tool only. Do not use it in production! Advice on how to do this using different Dart entrypoints can be found here.

(1) Create your Mockzilla server config and add mocked endpoints.

final mockzillaConfig = MockzillaConfig().addEndpoint(
    () => EndpointConfig(
        name: "Hello world",
        endpointMatcher: (request) => request.uri.endsWith("/hello-world"),
        defaultHandler: (request) => const MockzillaHttpResponse(
            body: jsonEncode(const HelloWorldResponse())),
        ),
        errorHandler: (request) => const MockzillaHttpResponse(
            statusCode: 418,
        ),
    ),
);

(2) Start the mock server!

// Make sure to call this before starting Mockzilla!
WidgetsFlutterBinding.ensureInitialized();

await Mockzilla.startMockzilla(mockzillaConfig);

Mockzilla Desktop #

The Mockzilla Desktop application lets you inspect and configure the mocked endpoints at runtime. You can manipulate the responses and adjust simulated latency on a connected device.

More information about Mockzilla Desktop can be found here.

ℹ️ Note: Mockzilla Desktop replaces the web console from version 1.0.0 onwards. The web console is now deprecated and will eventually be retired.

8
likes
160
points
1.55k
downloads

Publisher

verified publisherapadmi.com

Weekly Downloads

A solution for configuring and running a local HTTP server as part of a Flutter app.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#http #server #tool #mockzilla

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, mockzilla_android, mockzilla_ios, mockzilla_platform_interface

More

Packages that depend on mockzilla