DioAdapter class
HttpClientAdapter
extension with data mocking and recording functionality.
Constructors
- DioAdapter({required Dio dio, HttpRequestMatcher matcher = const FullHttpRequestMatcher(), bool printLogs = false})
-
Constructs a DioAdapter 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
-
close(
{bool force = false}) → void - Closes the DioAdapter by force.
-
fetch(
RequestOptions requestOptions, Stream< Uint8List> ? requestStream, Future? cancelFuture) → Future<ResponseBody> -
DioAdapter`s fetch configuration intended to work with mock data.
Returns a Future<ResponseBody> from history based on
RequestOptions
. -
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 -
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 -
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