MagicNetworkInterceptor class abstract

The Magic Network Interceptor contract.

Driver-agnostic interceptor for modifying requests, responses, and errors. Each driver translates to/from these types.

class LoggingInterceptor extends MagicNetworkInterceptor {
  @override
  MagicRequest onRequest(MagicRequest request) {
    print('Request: ${request.method} ${request.url}');
    return request;
  }

  @override
  MagicResponse onResponse(MagicResponse response) {
    print('Response: ${response.statusCode}');
    return response;
  }
}
Implementers

Constructors

MagicNetworkInterceptor()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(MagicError error) → dynamic
Called when an error occurs.
onRequest(MagicRequest request) → dynamic
Called before each request is sent.
onResponse(MagicResponse response) → dynamic
Called after a successful response is received.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited