Pick class

A picked object holding the value (may be null) and giving access to useful parsing functions

Available extensions

Constructors

Pick(Object? value, {List<Object> path = const [], Map<String, dynamic>? context})
Pick constructor when being able to drill down path all the way to reach the value. value may still be null but the structure was correct, therefore isAbsent will always return false.
Pick.absent(int missingValueAtIndex, {List<Object> path = const [], Map<String, Object?>? context})
Pick of an absent value. While drilling down path the structure of the data did not match the path and the value wasn't found.

Properties

context Map<String, dynamic>
Attaches additional information which can be used during parsing. i.e the HTTP request/response including headers
final
debugParsingExit String
Returns a human readable String of the requested path and the actual parsed value following the path along (followablePath).
no setter
followablePath List<Object>
The path segments containing non-null values parsing could follow along
no setter
hashCode int
The hash code for this object.
no setterinherited
index int?
The index of the object when it is an element in a List
no setter
isAbsent bool
Allows the distinction between the actual value null and the value not being available
no setter
missingValueAtIndex int?
When the picked value is unavailable (Pick.isAbsent) the index in path which couldn't be found
no setter
path List<Object>
The full path to value inside of the object
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value Object?
The picked value, might be null
final

Methods

asBoolOrFalse() bool

Available on Pick, provided by the BoolPick extension

Returns the picked value as bool or defaults to false when the value is null or can't be interpreted as bool.
asBoolOrNull() bool?

Available on Pick, provided by the BoolPick extension

Returns the picked value as bool or null if it can't be interpreted as bool.
asBoolOrThrow() bool

Available on Pick, provided by the BoolPick extension

Returns the picked value as bool or throws a PickException
asBoolOrTrue() bool

Available on Pick, provided by the BoolPick extension

Returns the picked value as bool or defaults to true when the value is null or can't be interpreted as bool.
asDateTimeOrNull({PickDateFormat? format}) DateTime?

Available on Pick, provided by the NullableDateTimePick extension

Parses the picked value as ISO 8601 String to DateTime or returns null
asDateTimeOrThrow({PickDateFormat? format}) DateTime

Available on Pick, provided by the NullableDateTimePick extension

Parses the picked value as ISO 8601 String to DateTime or throws
asDoubleOrNull() double?

Available on Pick, provided by the NullableDoublePick extension

Returns the picked value as double? or returns null when the picked value is absent
asDoubleOrThrow() double

Available on Pick, provided by the NullableDoublePick extension

Returns the picked value as double or throws
asIntOrNull({bool roundDouble = false, bool truncateDouble = false}) int?

Available on Pick, provided by the NullableIntPick extension

Returns the picked value as int? or returns null when the picked value is absent
asIntOrThrow({bool roundDouble = false, bool truncateDouble = false}) int

Available on Pick, provided by the NullableIntPick extension

Returns the picked value as int or throws
asListOrEmpty<T>(T map(RequiredPick), {T whenNull(Pick pick)?}) List<T>

Available on Pick, provided by the NullableListPick extension

Returns the picked value as List or an empty list when the value isn't a List or isAbsent.
asListOrNull<T>(T map(RequiredPick), {T whenNull(Pick pick)?}) List<T>?

Available on Pick, provided by the NullableListPick extension

Returns the picked value as List or null when the value isn't a List or isAbsent.
asListOrThrow<T>(T map(RequiredPick), {T whenNull(Pick pick)?}) List<T>

Available on Pick, provided by the NullableListPick extension

Returns the picked value as List. This method throws when value is not a List or isAbsent
asMapOrEmpty<RK, RV>() Map<RK, RV>

Available on Pick, provided by the NullableMapPick extension

Returns the picked value as Map or an empty map when the value isn't a Map or isAbsent.
asMapOrNull<RK, RV>() Map<RK, RV>?

Available on Pick, provided by the NullableMapPick extension

Returns the picked value as Map or null when the value isn't a Map or isAbsent.
asMapOrThrow<RK, RV>() Map<RK, RV>

Available on Pick, provided by the NullableMapPick extension

Returns the picked value as Map. This method throws when value is not a Map or isAbsent
asStringOrNull() String?

Available on Pick, provided by the NullableStringPick extension

Returns the picked value as String or returns null when the picked value isn't available
asStringOrThrow() String

Available on Pick, provided by the NullableStringPick extension

Returns the picked value as String representation; only throws a PickException when the value is null or isAbsent.
call([Object? arg0, Object? arg1, Object? arg2, Object? arg3, Object? arg4, Object? arg5, Object? arg6, Object? arg7, Object? arg8, Object? arg9]) Pick
fromContext(String key, [Object? arg0, Object? arg1, Object? arg2, Object? arg3, Object? arg4, Object? arg5, Object? arg6, Object? arg7, Object? arg8]) Pick
Pick values from the context using the Pick API
letOrNull<R>(R? block(RequiredPick pick)) → R?

Available on Pick, provided by the NullableLet extension

Maps the pick if value != null and returns the result.
letOrThrow<R>(R block(RequiredPick pick)) → R

Available on Pick, provided by the NullableLet extension

Maps the non-null value and returns the result. Throws when value == null
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
required() RequiredPick
Enter a "required" context which requires the picked value to be non-null or a PickException is thrown.
toString() String
A string representation of this object.
override
withContext(String key, Object? value) Pick
Attaches additional information which can be used during parsing. i.e the HTTP request/response including headers

Operators

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