mockrec library

A lightweight Dio interceptor that records real API responses and replays them without hitting the backend.

Quick Start

import 'package:dio/dio.dart';
import 'package:mockrec/mockrec.dart';

final dio = Dio();

// Attach the interceptor
Mockrec.enable(dio);

// Normal mode — records API responses
await dio.get('/user');

// Enable mock mode — replays from memory
Mockrec.setMockMode(true);
await dio.get('/user'); // returns recorded response

Classes

MockInterceptor
A Dio Interceptor that records API responses and replays them.
Mockrec
Lightweight API recorder for Dio.
MockStorage
Global in-memory storage for recorded API responses.

Functions

generateKey(RequestOptions request) String
Generates a unique cache key from a RequestOptions instance.