Parse class
Helps to parse basic objects.
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
-
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
Static Methods
-
convert<
T> (dynamic value, {required ValueConverter< T> converter, T? defaultValue}) → T? -
Safety converts value to give Type
If conversion fails, then is
defaultValue
returned. -
convertEntry<
T> (dynamic key, dynamic value, {required EntryConverter< T> converter, T? defaultValue}) → T? -
Safety converts value to give Type
If conversion fails, then is
defaultValue
returned. -
date(
dynamic value, {bool inSec = false}) → DateTime? -
Tries to parse
value
int DateTime -
fill<
K, V> (Map< K, V> map) → Map<K, V> -
Creates copy of given
map
and filters outnull
values. Also empty Iterable or String is not included in returned Map. -
format(
String input, Map< String, String> params, [ParamDecoratorFormat? decorator]) → String -
Replaces
params
ininput
string Simply replaces strings with params. For more complex formatting can be better to useIntl
. Set custom ParamDecoratorFormat to decorate param, for example: 'city' => '{city}' or 'city' => '$city' -
fromEnum(
dynamic value) → String? -
Returns name of given enum
value
. If givenvalue
is empty or not enum, null is returned. -
getArg<
T> (dynamic value, {dynamic key, bool predicate(dynamic)?, T? defaultValue}) → T? -
Tries to return item of given
key
or Type. If none found, thendefaultValue
is returned. Currently supports Parse.getArgFromMap, Parse.getArgFromList and Parse.getArgFromString -
getArgFromList<
T> (Iterable? iterable, {bool predicate(dynamic)?, T? defaultValue}) → T? -
Tries to return object of given Type or
predicate
. If none found, thendefaultValue
is returned. -
getArgFromMap<
T> (Map? map, {dynamic key, bool predicate(dynamic)?, T? defaultValue}) → T? -
Tries to return item of given
key
, Type orpredicate
. Ifkey
is not specified, then Parse.getArgFromList is used. If none found, thendefaultValue
is returned. -
getArgFromString<
T> (String? value, {dynamic key, bool predicate(dynamic)?, T? defaultValue}) → T? -
Converts input
value
to json, then tries to return object of givenkey
, Type orpredicate
. If none found, thendefaultValue
is returned. -
name(
dynamic value) → String -
Converts given
value
to String - inputvalue
name is parsed based on Type. Primitives are just converted to String. For Enum value name is parsed. Otherwise Type name is returned. -
nullableType<
T> () → bool -
Returns 'true' if
T
is nullable. -
string(
dynamic value, {String defaultValue = ''}) → String - Tries to parse value into String.
-
toArgs(
dynamic value, {dynamic data}) → Map -
Converts
value
and additionaldata
into Map of arguments. Check ControlArgs for more info. -
toBool(
dynamic value, {bool defaultValue = false}) → bool - Tries to parse value into bool.
-
toDouble(
dynamic value, {double defaultValue = 0.0}) → double - Tries to parse value into double.
-
toEnum<
T> (dynamic value, List< T> enums, {T? defaultValue}) → T -
Parse input
value
to String and then to enum. Parsing is case insensitive. If enum of given name is not found,defaultValue
or first value fromenums
is returned. -
toInteger(
dynamic value, {int defaultValue = 0}) → int -
Tries to parse value into
integer
. -
toKeyMap<
K, T> (dynamic value, EntryConverter< K> keyConverter, {ValueConverter<T> ? converter, EntryConverter<T> ? entryConverter}) → Map<K, T> - Tries to parse value into Map.
-
toList<
T> (dynamic value, {ValueConverter< T> ? converter, EntryConverter<T> ? entryConverter, bool hardCast = false}) → List<T> - Tries to parse value into List.
-
toMap<
T> (dynamic value, {ValueConverter< T> ? converter, EntryConverter<T> ? entryConverter, bool hardCast = false}) → Map<dynamic, T> - Tries to parse value into Map.
-
type<
T> ([dynamic value]) → Type -
Returns Type from given
T
orvalue
. Returnsdynamic
ifT
is not passed andvalue
isnull
.