FormInput class

Turns text input (query string, form data) into nested maps and lists, for a DTO.

  • A repeated key gives a list: tags=a&tags=b.
  • Bracket keys nest: address[city]=x, tags[]=a, items[0][name]=x.
  • List indexes are sorted and packed: items[3] alone is one item.

At most maxItems items in a list and maxDepth levels, else 422.

Constructors

FormInput()
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

nested(Map<String, dynamic> flat, Iterable<MapEntry<String, Object>> pairs()) → Map<String, dynamic>
The input for req.body and req.query, like PHP and Laravel: bracket keys nest (tags[]=a&tags[]=b gives {'tags': ['a', 'b']}), and a repeated plain key keeps its last value. flat (the last value of each key) is given back as it is when no key has a [, so most requests skip the work.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pairs(String text) → List<MapEntry<String, Object>>
The (key, value) pairs of an urlencoded text, in order. A bad % code throws a BadRequestException.
parse(Iterable<MapEntry<String, Object>> pairs) → Map<String, dynamic>
The nested input of pairs (key, value), in order.
query(Uri uri) → Map<String, dynamic>
The input of a query string, with repeated keys.
queryPairs(Uri uri) → List<MapEntry<String, Object>>
The (key, value) pairs of the query string of uri.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

maxDepth → const int
maxItems → const int