dio_mocked_responses 0.9.0 copy "dio_mocked_responses: ^0.9.0" to clipboard
dio_mocked_responses: ^0.9.0 copied to clipboard

Interceptor that help you to mock backend responses in flutter project.

example/lib/main.dart

import 'dart:convert';

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

void main() async {
  Dio dio = Dio(BaseOptions());

  dio.interceptors.add(MockInterceptor());

  Response response =
      await dio.post("/api/basic/data"); // the same path as common.json
  String json = response.data;
  if (json.isEmpty) {
    throw Exception('response is empty');
  }

  Map<String, dynamic> data = jsonDecode(json);
  bool isSuccess = data['success'] as bool;
  print(isSuccess); // true
  Map<String, dynamic> result = data['result'];
  print(result['test']); //test
}
5
likes
125
points
107
downloads

Publisher

verified publisherbenoitfontaine.fr

Weekly Downloads

Interceptor that help you to mock backend responses in flutter project.

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, template_expressions

More

Packages that depend on dio_mocked_responses