mockzilla 4.0.0
mockzilla: ^4.0.0 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.
| Android | iOS | |
|---|---|---|
| Support | SDK 24+ (Target SDK 36) | 15.0+ |
Quick Start π #
Head to the quick start guide to get up and running, or jump straight to a specific topic:
To hit the ground running #
(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);
Why's it useful? π #
Development servers go down, endpoints can be late being delivered or not exist at all! Mockzilla aims to easily provide a way of simulating your server from within your mobile application's codebase.
Advantages #
β Compile safe mock endpoint definitions.
β HTTP client agnostic.
β Works completely offline.
β Entirely self-contained in your application's codebase.
β Edit responses live from a desktop app or an in-app overlay β no rebuild required.
β Presets for one-tap switching between success, error, and edge-case responses.
Control mocks live, while your app runs ποΈ #
Beyond defining mocks in code, Mockzilla ships two ways to change what's returned while your app is running β force an endpoint to fail, add artificial latency, or apply a preset, all without touching code or rebuilding:
- Mockzilla Desktop: A companion app that connects to your device over Wifi.
- Mockzilla Mobile UI: An overlay you embed directly in your app.

Why not use a hosted solution? βοΈ #
Hosted mocking solutions can be powerful mocking tools in many cases. They have their downsides:
- They can go down, Mockzilla works offline!
- There's no compile-time checking
- They require active maintenance with no compile-time safety if APIs change.
Important Note π #
Mockzilla is designed as a development and test tool only.
Mockzilla should never be used in production. Its traffic is unprotected and by nature of running a server on device, it can introduce security issues. Advice on how to do this using different Dart entrypoints can be found here.
Do not ship it to production.
Contributing #
Contributions are welcome! See CONTRIBUTING.md for how to get set up.