Repository navigation
v1.2.0
-
Better error messages #64, especially for absent values
PickException: expected a non-null value at shoes[0].name, but it is absent query shoes[0].name ~~~~ no such key at shoes[0] = {"id": 42, "size": "M"} hint Use asStringOrNull() when the value may be null/absent at some point (String?).A value that can't be parsed is shown with its type, and large values are shortened.
PickException: could not parse an int at shoes[0].size query shoes[0].size found "M" (a String) -
New
asJsonObjectOrThrow(),asJsonObjectOrEmpty()andasJsonObjectOrNull()return aMap<String, Object?>that goes straight into afromJsonfunction, no type arguments needed #70.
Entries with a key that isn't aStringare ignored. -
New
asJsonObjectListOrThrow(),asJsonObjectListOrEmpty()andasJsonObjectListOrNull()for a list of JSON objects #70.// before pick(json, 'users').asListOrEmpty((pick) => pick.asMapOrThrow<String, dynamic>()); // after pick(json, 'users').asJsonObjectListOrEmpty();
-
New
asMapListOrThrow<K, V>(),asMapListOrEmpty<K, V>()andasMapListOrNull<K, V>()for a list of maps with any key type #70. -
Fix
Pick.isAbsentistruebelow anull, however the path is written #64.
pick({'a': null}, 'a', 'b').isAbsentwasfalse, whilepick({'a': null}, 'a')('b').isAbsentwastrue. -
New
PickException.fromPick(pick, 'expected a Timestamp')lets custom parsers throw errors like the built-in ones #64. -
New
Pick.redactValues()masks error values while keeping keys and types visible;Pick.redactsValuesexposes the policy to custom parsers andRequiredPick.redactValues()preserves non-null chaining #65. -
Fix
as*OrThrow()andletOrThrow()no longer leave an internal_required_pick_error_hintentry inPick.context.
That also makes them as fast as theirOrNullcounterparts #68. -
Deprecated
Pick.path,Pick.missingValueAtIndex,Pick.followablePathandPick.debugParsingExit.
The error message of aPickExceptionshows where a pick failed.
A custom parser that built its message from them throwsPickException.fromPick(this, 'expected a Foo')instead #69.