Method class

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

Constructors

Method(String method, {bool optionalBody = false, String path = '', Map<String, String> headers = const {}, bool useBrackets = false, bool includeNullQueryVars = false})
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
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