Skip to content
pubscout

mockzilla

4.0.0, released 3 months ago by apadmi.com

Run a local mock HTTP server inside your Flutter app for REST API testing.

WASM-ready
$ flutter pub add mockzilla
Source repository

What it does

Configures and runs a local HTTP server directly within your Flutter application to simulate REST API calls. It allows developers to define mock endpoints and behaviors in code, and offers live control via a companion desktop app or an embedded mobile UI overlay.

AI-written summary of version 4.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to simulate a REST backend during development or testing
  • Backend endpoints are delayed, under construction, or unreliable
  • You need to switch between success and error response presets at runtime

Skip it when

  • You are building for production
  • You prefer external hosted mocking solutions

Strengths

  • Compile-safe mock endpoint definitions
  • Works completely offline without a backend dependency
  • Live response editing via a desktop app or in-app UI without rebuilding

Weaknesses

  • Unprotected traffic and running a server on-device introduces security issues, making it unsuitable for production
  • Limited platform support (Android, iOS, and Web)

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
4

Ensure WidgetsFlutterBinding.ensureInitialized() is called before starting Mockzilla. Requires minimum Android SDK 24 (Target SDK 36) and iOS 15.0+.

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,
        ),
    ),
);

WidgetsFlutterBinding.ensureInitialized();
await Mockzilla.startMockzilla(mockzillaConfig);

Alternatives

Packages that do the same job and could replace mockzilla.

  • fluttersdk_dusk

    Flutter E2E test driver for LLM agents and CLI via VM Service extensions without a test harness.

  • charlatan

    Configure and provide fake HTTP responses to the dio HTTP client for testing.