Method constructor

const Method(
  1. String method, {
  2. bool optionalBody = false,
  3. String path = '',
  4. Map<String, String> headers = const {},
  5. ListFormat? listFormat,
  6. @Deprecated('Use listFormat instead') bool? useBrackets,
  7. 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,
});