ezmock 1.1.0
ezmock: ^1.1.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 #
EZMock 1.1.0 groups mock responses by endpoint and HTTP method, supports shared scenarios and common HTTP errors, and builds the scenario picker from your routes.
Install 1.1.0 #
Install EZMock 1.1.0 from pub.dev.
flutter pub add ezmock:1.1.0
Use schemaVersion: 2 for your route manifest.
Endpoint manifest guide · Upgrade from 1.0.0
Start the server #
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.
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 picker shows named scenarios from routes.json and shows
only groups with configured options. 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.