AssertableJsonBase class abstract
An abstract base class for assertable JSON data.
This class provides a set of utility methods for working with JSON data, including type-safe access to values, lists, and maps. It also includes a mixin for handling interactions, which can be used for testing or other purposes.
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- json → dynamic
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
assertEmpty(
[String? path]) → void -
Asserts that the value at the specified
pathis empty. -
each(
dynamic callback(AssertableJson)) → AssertableJson -
Iterates over the JSON data, either an array or an object, and calls the provided
callbackfunction for each element. -
etc(
) → AssertableJson -
Marks all properties in the JSON object as accessed.
inherited
-
exists(
String path) → bool -
Checks if the specified
pathexists within the JSON data. -
first(
dynamic callback(AssertableJson)) → AssertableJson - Scopes the current AssertableJson instance to the first element of the JSON data.
-
get<
T> (String path) → T? -
Gets the value at the specified
pathand casts it to the specified typeT. -
getList<
T> (String path) → List< T> -
Gets a list of items at the specified
pathand casts them to the specified typeT. -
getMap<
T> (String path) → Map< String, T> -
getRequired<
T> (String path) → T -
Gets the value at the specified
pathand casts it to the specified typeT. -
interactsWith(
String key) → void -
Records an interaction with the specified JSON property
key.inherited -
keys(
[String? path]) → List< String> -
Gets a list of all keys at the specified
pathin the JSON data. -
length(
[String? path]) → int -
Gets the length of the JSON data at the specified
path. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scope(
String key, dynamic callback(AssertableJson)) → AssertableJson -
Scopes the current AssertableJson instance to the specified
keyand calls the providedcallbackfunction with the scoped instance. -
toString(
) → String -
A string representation of this object.
inherited
-
values<
T> ([String? path]) → List< T> -
Gets a list of all the values at the specified
pathwithin the JSON data. -
verifyInteracted(
) → void -
Verifies that all properties in the JSON object have been accessed.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited