Method class sealed

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.

Implementers
Annotations
  • @immutable
  • @Target({TargetKind.method})

Constructors

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.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Headers Map that should be apply to the request
final
includeNullQueryVars bool?
Set to true to include query variables with null values. This includes nested maps. The default is to exclude them.
final
listFormat ListFormat?
List format to use when encoding lists
final
method String
HTTP method for the request
final
optionalBody bool
Mark the body as optional to suppress warnings during code generation
final
path String
Path to the request that will be concatenated with the ChopperApi.baseUrl.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useBrackets bool?
Use brackets [ ] to when encoding
final

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