DioInterceptor class
DioInterceptor is a class for mocking Dio
requests with Interceptor
.
Constructors
- DioInterceptor({required Dio dio, HttpRequestMatcher matcher = const FullHttpRequestMatcher(), bool printLogs = false, bool failOnMissingMock = true})
-
Constructs a DioInterceptor and configures the passed
Dio
instance.
Properties
- dio → Dio
-
final
- failOnMissingMock → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
history
→ List<
RequestMatcher> -
Keeps track of request and response history.
no setterinherited
- logger ↔ Logger
-
getter/setter pair
- matcher → HttpRequestMatcher
-
final
- mockResponse → MockResponseBodyCallback
-
Getter for the current request invocation's intended mockResponse.
no setterinherited
- printLogs → bool
-
final
- requestMatcher → RequestMatcher
-
Gets current
RequestMatcher
.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
isMockDioException(
MockResponse mockResponse) → bool -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDelete(
Pattern route, MockServerCallback requestHandlerCallback, {dynamic data, Map< String, dynamic> ? queryParameters, Map<String, dynamic> ? headers}) → void -
Takes in a route, requests with RequestMethods.delete,
and sets corresponding
RequestHandler
.inherited -
onError(
DioException err, ErrorInterceptorHandler handler) → void -
Called when an exception was occurred during the request.
inherited
-
onGet(
Pattern route, MockServerCallback requestHandlerCallback, {dynamic data, Map< String, dynamic> ? queryParameters, Map<String, dynamic> ? headers}) → void -
Takes in a route, requests with RequestMethods.get,
and sets corresponding
RequestHandler
.inherited -
onHead(
Pattern route, MockServerCallback requestHandlerCallback, {dynamic data, Map< String, dynamic> ? queryParameters, Map<String, dynamic> ? headers}) → void -
Takes in a route, requests with RequestMethods.head,
and sets corresponding
RequestHandler
.inherited -
onPatch(
Pattern route, MockServerCallback requestHandlerCallback, {dynamic data, Map< String, dynamic> ? queryParameters, Map<String, dynamic> ? headers}) → void -
Takes in a route, requests with RequestMethods.patch,
and sets corresponding
RequestHandler
.inherited -
onPost(
Pattern route, MockServerCallback requestHandlerCallback, {dynamic data, Map< String, dynamic> ? queryParameters, Map<String, dynamic> ? headers}) → void -
Takes in a route, requests with RequestMethods.post,
and sets corresponding
RequestHandler
.inherited -
onPut(
Pattern route, MockServerCallback requestHandlerCallback, {dynamic data, Map< String, dynamic> ? queryParameters, Map<String, dynamic> ? headers}) → void -
Takes in a route, requests with RequestMethods.put,
and sets corresponding
RequestHandler
.inherited -
onRequest(
RequestOptions requestOptions, RequestInterceptorHandler requestInterceptorHandler) → void -
Dio
Interceptor
`s onRequest configuration intended to catch and return mocked request and data respectively. -
onResponse(
Response response, ResponseInterceptorHandler handler) → void -
Called when the response is about to be resolved.
inherited
-
onRoute(
Pattern route, MockServerCallback requestHandlerCallback, {required Request request}) → void -
Takes in
route
,request
, sets correspondingRequestHandler
, adds an instance ofRequestMatcher
in history.inherited -
reset(
) → void -
Resets the history.
inherited
-
setDefaultRequestHeaders(
Dio dio, RequestOptions options) → Future< void> -
Configures default headers which are usually set by
DioMixin
.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited