OkMock

Dio interceptor for mocking HTTP request in Flutter

Prerequisite

Quick Start

Flutter Side

  1. Add OkMock as your dependency
dependencies:
  okmock: "0.0.1"
  1. Add OkMock as Dio interceptor
dio = Dio();
dio.interceptors.add(OkMock.createDefault(dio));

Desktop Side

  1. After install gadb, create mock file in json or yaml
{
  "path": "*google.com*",
  "method": "GET",
  "body": {
    "message": "hello mock"
  }
}
  1. Run gadb mock -f <file>

That's it! Now every time a request is matching the path and method, your request will return body

Example

You can also check out the flutter app example

License

MIT @ Esa Firman

Libraries

okmock
okmock_adapter
okmock_payload
okmock_server
partial_request