TrayPlugin class abstract
Abstract class for plugins to be used with FetchTray
The interceptors getter should return a list of interceptors to be used with the Dio instance, which can be used to modify the request or response before they are sent or returned.
The getRequestExtra method should return a map of extra data to be used in the request.
This data will be added to the Options.extra property and merged with other possible
plugins' extra data, so make sure to use unique keys.
This is useful for example to add a token to the request headers
class MyPlugin extends TrayPlugin {
@override
List<Interceptor> get interceptors => [
InterceptorsWrapper(
onRequest: (options, handler) {
// modify options here
return handler.next(options);
},
),
];
}
class MyPlugin extends TrayPlugin {
@override
Map<String, dynamic> getRequestExtra(TrayRequest request) {
return {
'foo': 'bar',
};
}
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
interceptors
→ List<
Interceptor> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getRequestExtra(
TrayRequest request) → Map< String, dynamic> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited