RequestBodyAccessor class

Reference class for different request body accessors. Provides basic accessors like asString or asJson.

You can extend on this class to add your own body parser.

Example:

extension PersonAccessor on RequestBodyAccessor {
  Future<Person> get asPerson async => Person.fromJson(await asJson);
}

Constructors

RequestBodyAccessor(Request request)

Properties

asBinary Stream<List<int>>
Returns the request body as a binary stream.
no setter
asJson Future
Returns the request body as json-decoded object, that can be either Map<String, dynamic> or List<dynamic>
no setter
asString Future<String>
Returns the request body as a utf8 string
no setter
hashCode int
The hash code for this object.
no setterinherited
request Request
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

as<T>(T reviver(Map<String, dynamic>)) Future<T>
Returns the request body as a class instance that is initialized by the provided reviver.
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