HttpStandardTransformer class

Standard response transformer

REST-Api directly returns the data structure, not package like HttpClassicTransformer.

var http = Http.getInstances(HttpBaseOptions({
  name: 'defaultApi',
  baseUrl: 'http://domain.com/api/v1',
  transformer: HttpStandardTransformer(
    errorCodeKey: 'code',
    errorMessageKey: 'message',
    errorDataKey: 'data',
  ),
}));
var res = await http.get('/users');
print(res.data); // "res.data" in "response.data" for Dio

Using the HTTP statuscode to determine if an error has occurred, the error is structured as follows:

{
  code: <int>,
  message: <String>,
  data: <AnyType>
}

HttpError will be thrown when an error occurs.

Inheritance

Constructors

HttpStandardTransformer({String errorCodeKey = 'code', String errorMessageKey = 'message', String errorDataKey = 'data'})

Properties

errorCodeKey String
final
errorDataKey String
final
errorMessageKey String
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

errorHandler(DioError err) HttpError
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
transformer<T>(Response<T> response) Future<Response<T>>
override

Operators

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