FactoryConverter class final

Defines custom Converter methods for a single network API endpoint. See ConvertRequest, ConvertResponse.

@ChopperApi(baseUrl: '/todos')
abstract class TodosListService extends ChopperService {
  static TodosListService create([ChopperClient client]) =>
      _$TodosListService(client);

  static FutureOr<Request> customRequestConverter(Request request) {
    return request.copyWith(
        body: // Convert request.body the way your API needs it. See [JsonConverter.encodeJson] for an example.
    );
  }

  static FutureOr<Response> customResponseConverter(Response response) {
    return response.copyWith(
      body: // Convert response.body the way your API needs it. See [JsonConverter.decodeJson] for an example.
    );
  }

  @Get(path: "/{id}")
  @FactoryConverter(
    request: customRequestConverter,
    response: customResponseConverter
  )
  Future<Response<Todo>> getTodo(@Path("id"));
}
Annotations
  • @immutable
  • @Target({TargetKind.method})

Constructors

FactoryConverter({ConvertRequest? request, ConvertResponse? response})
Defines custom Converter methods for a single network API endpoint. See ConvertRequest, ConvertResponse.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
request ConvertRequest?
final
response ConvertResponse?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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