useJustJson function

RequestInterceptor useJustJson({
  1. required String jsonString,
  2. Duration? responseTime,
  3. int statusCode = 200,
})

Implementation

RequestInterceptor useJustJson({
  required String jsonString,
  Duration? responseTime,
  int statusCode = 200,
}) {
  return RequestInterceptor(interceptor: (Request request) async {
    if (responseTime != null) await Future.delayed(responseTime);
    var m = jsonDecode(jsonString);
    return RequestInterceptorFlow(request,
        terminate: true,
        response: Response(
          statusCode: statusCode,
          data: m,
          body: jsonString,
        ));
  });
}