mockzilla 3.0.0-dev
mockzilla: ^3.0.0-dev 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 23+ (Target SDK 36) | 13.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.