Skip to main content

ezmock 1.0.0 copy "ezmock: ^1.0.0" to clipboard
ezmock: ^1.0.0 copied to clipboard

Client-independent API mocking for Flutter mobile and desktop with a Dart loopback server.

EZMock for Flutter #

Mock APIs. Build independently.

Build features before your backend is ready. Bundle JSON fixtures, start a local HTTP server, and give its URL to the HTTP client you already use. Keep your services, DTOs, repositories and UI on the normal request path.

The Flutter SDK owns its Dart runtime on Android, iOS, macOS, Windows and Linux. It can be resolved independently of the Android and iOS EZMock SDKs. Flutter Web is outside this release scope because browsers cannot open the embedded listener.

Get started #

Install EZMock from pub.dev with flutter pub add ezmock:1.0.0. To work on the SDK from source, use a local checkout:

dependencies:
  ezmock:
    path: ../ezmock-flutter

Bundle assets/mocks/routes.json and your response files using the normal Flutter asset declarations. In your existing HTTP client setup:

import 'package:ezmock/ezmock.dart';

final baseUrl = await EZMock.start();

Pass baseUrl to Dio, package:http, or another HTTP client that accepts a configurable HTTP URL. Configure the host permissions for local HTTP where required. See installation and platform setup and routes, scenarios and examples.

To point the same client at a real backend, supply its real base URL. The SDK also accepts EZMock.start(enabled: false, liveBaseUrl: liveBaseUrl) for a shared setup function. Call EZMock.stop() when your development server owner is finished. A newly started server receives a fresh port, so rebuild clients that were bound to the earlier URL.

Development controls #

Use the optional EZMockScenarioButton() and EZMockInspectionButton() in your toolbar. The scenario picker selects fixtures by name, status or response state. The Requests screen captures mock exchanges with status, timing, headers and JSON previews. Authentication and cookie headers are redacted. Keep fixture and request data synthetic.

Example and contribution #

Open example to try a normal Users feature on mobile or desktop. The app covers read, create, edit, delete and simulated failures. See contributing and the verification guide for runtime ownership and local checks.

The server listens on IPv4 loopback and responds over plain HTTP. Use a real service when testing TLS, certificates, or backend persistence.

0
likes
140
points
--
downloads

Documentation

API reference

Publisher

verified publisherezmock.io

Weekly Downloads

Client-independent API mocking for Flutter mobile and desktop with a Dart loopback server.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, material_ui, shared_preferences

More

Packages that depend on ezmock