DioRequest<T> class
abstract
Main implementation for Http requests using Dio
class HttpRequest<T> extends DioRequest<T> {
HttpRequest() : super();
@override
RequestSettings get defaultSettings => RequestSettings(
logPrint: (message) {},
exceptionPrint: (error, trace) {},
);
@override
void onAuthorization(Dio dio) {
// ignore
}
@override
Future onError(DioError error, RetryHandler retry) {
return retry();
}
}
- Inheritance
-
- Object
- BaseRequest<
T> - DioRequest
Constructors
Properties
-
additionalInterceptors
↔ Iterable<
Interceptor> -
Aditional interceptors for
Dio
instancegetter/setter pairinherited - baseUrl ↔ String?
-
Base url for request
getter/setter pairinherited
- body ↔ dynamic
-
Body for this request
getter/setter pairinherited
- cancelToken ↔ CancelToken
-
Dio cancel token for this request
changes after every execute call
getter/setter pair
-
databaseGetDelegate
↔ DatabaseGetDelegate<
T> ? -
Delegate to get data from local database
getter/setter pairinherited
-
databasePutDelegate
↔ DatabasePutDelegate<
T> ? -
Delegate to put data to local database
getter/setter pairinherited
- defaultSettings → RequestSettings
-
Default settings for all requests
no setter
- dioInstance → Dio?
-
Underlying
Dio
instanceno setteroverride - forceReturnNullFromRequest ↔ bool
-
Test flag to return null response
getter/setter pair
-
formData
↔ Future<
FormData> ? -
Form data for this request
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
↔ Map<
String, dynamic> ? -
Headers for this request
getter/setter pairinherited
- ignoreCancelations ↔ bool
-
Flag indicating that this request cant be canceled from RequestCollection
getter/setter pairinherited
- method ↔ RequestMethod
-
Http request method
getter/setter pairinherited
- onPrefetchFromDatabase ↔ void Function(T?)?
-
getter/setter pairinherited
-
parser
↔ ResponseParser<
T> ? -
Parser function for this request
getter/setter pairinherited
-
query
↔ Map<
String, dynamic> ? -
Query for this request - will be added to the end of the url
getter/setter pairinherited
- requestCollection → RequestCollection
-
Collection of all running requests
no setterinherited
- requiresLogin ↔ bool
-
Flag to indicate that we need to add autharization headers to this request
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- simulateResponse ↔ SimulateResponse?
-
For tests: simulates unparsed raw server response
getter/setter pairinherited
-
simulateResult
↔ Response<
T> ? -
For tests: simulates parsed result for this request
getter/setter pairinherited
- timeout ↔ Duration?
-
Summary timeout for connect and receive timeouts
getter/setter pairinherited
- url ↔ String?
-
Url to be added to baseUrl - always starts with /
getter/setter pairinherited
Methods
-
cancel(
) → void -
Cancels current request if it is still executing
override
-
constructRequest(
Dio client, RequestMethod method, dynamic encodedData) → Future< Response> - Adds data to dio, adds autharization headers if needed and returns Future with request results
-
execute(
) → Future< Response< T> > -
Executes this request and returns Response value
override
-
getFromDatabase(
) → Future< void> - Gets cached data from database if prefetch handler provided to request
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAuthorization(
Dio dio) → void -
Function to add authorization headers to
Dio
instance -
onError(
DioException error, RetryHandler retry) → Future - Function to retry error requests
-
processDioException(
DioException exception, Dio client, dynamic data) → Future< Response< T> > -
Processes generic
DioException
-
processNoResponse(
) → Future< Response< T> > - Processes empty dio response
-
simulateResultStep(
) → Future< Response< T> ?> - Returns simulated result for dio request if simulate result value is provided
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited