Method constructor
const
Method(
- String method, {
- bool optionalBody = false,
- String path = '',
- Map<
String, String> headers = const {}, - ListFormat? listFormat,
- @Deprecated('Use listFormat instead') bool? useBrackets,
- bool? includeNullQueryVars,
Defines an HTTP method.
Must be used inside a ChopperApi definition.
Recommended: Get, Post, Put, Delete, Patch, or Head should be used instead.
@Get(headers: const {'foo': 'bar' })
Future<Response> myGetRequest();
The annotated method must always return a Future<Response>.
The Response type also supports typed parameters like Future<Response<MyObject>>
.
However, chopper will not automatically convert the body response to your type.
A Converter needs to be specified for conversion.
Implementation
const Method(
this.method, {
this.optionalBody = false,
this.path = '',
this.headers = const {},
this.listFormat,
@Deprecated('Use listFormat instead') this.useBrackets,
this.includeNullQueryVars,
});