Parameter class

A wrapper for a single parameter to a server method.

This provides numerous functions for asserting the type of the parameter in question. These functions each have a version that asserts that the parameter exists (for example, asNum and asString) and a version that returns a default value if the parameter doesn't exist (for example, asNumOr and asStringOr). If an assertion fails, the request is automatically rejected.

This extends Parameters to make it easy to access nested parameters. For example:

// "params.value" is "{'scores': {'home': [5, 10, 17]}}"
params['scores']['home'][2].asInt // => 17
Inheritance

Properties

asBool bool
Asserts that value exists and is a boolean and returns it. [...]
read-only
asDateTime DateTime
Asserts that value exists, is a string, and can be parsed as a DateTime and returns it. [...]
read-only
asInt int
Asserts that value exists and is an integer and returns it. [...]
read-only
asList List
Asserts that value exists and is a List and returns it. [...]
read-only, override
asMap Map
Asserts that value exists and is a Map and returns it. [...]
read-only, override
asNum num
Asserts that value exists and is a number and returns it. [...]
read-only
asString String
Asserts that value exists and is a string and returns it. [...]
read-only
asUri Uri
Asserts that value exists, is a string, and can be parsed as a Uri and returns it. [...]
read-only
exists bool
Whether this parameter exists.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
method String
The name of the method that this request called.
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
value → dynamic
The underlying value of the parameters object. [...]
read-only, inherited

Methods

asBoolOr(bool defaultValue) bool
Asserts that value is a boolean and returns it. [...]
asDateTimeOr(DateTime defaultValue) DateTime
Asserts that value exists, is a string, and can be parsed as a DateTime and returns it. [...]
asIntOr(int defaultValue) int
Asserts that value is an integer and returns it. [...]
asListOr(List defaultValue) List
Asserts that value is a List and returns it. [...]
asMapOr(Map defaultValue) Map
Asserts that value is a Map and returns it. [...]
asNumOr(num defaultValue) num
Asserts that value is a number and returns it. [...]
asStringOr(String defaultValue) String
Asserts that value is a string and returns it. [...]
asUriOr(Uri defaultValue) Uri
Asserts that value exists, is a string, and can be parsed as a Uri and returns it. [...]
valueOr(dynamic defaultValue) → dynamic
Returns value, or defaultValue if this parameter wasn't passed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited
operator [](dynamic key) Parameter
Returns a single parameter. [...]
inherited