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.
no setter
asDateTime DateTime
Asserts that value exists, is a string, and can be parsed as a DateTime and returns it.
no setter
asInt int
Asserts that value exists and is an integer and returns it.
no setter
asList List
Asserts that value exists and is a List and returns it.
no setteroverride
asMap Map
Asserts that value exists and is a Map and returns it.
no setteroverride
asNum num
Asserts that value exists and is a number and returns it.
no setter
asString String
Asserts that value exists and is a string and returns it.
no setter
asUri Uri
Asserts that value exists, is a string, and can be parsed as a Uri and returns it.
no setter
exists bool
Whether this parameter exists.
no setter
hashCode int
The hash code for this object.
no setterinherited
method String
The name of the method that this request called.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → dynamic
The underlying value of the parameters object.
no setterinherited

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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
valueOr(dynamic defaultValue) → dynamic
Returns value, or defaultValue if this parameter wasn't passed.

Operators

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