JsonList<T extends JsonModel> class

A specialized JSON field for handling lists of JsonModel objects.

JsonList extends JsonField<List<T>> to provide type-safe handling of arrays of model objects in JSON data. It automatically deserializes JSON arrays into lists of model instances and provides indexed access to elements.

Key Features:

  • Automatic deserialization of JSON arrays to model lists
  • Indexed access using [] and []= operators
  • Defaults to empty list when value is null
  • Type-safe list operations with generic type parameter

Type Parameter:

  • T: The type of JsonModel objects in the list (e.g., UserModel, ProductModel).

Usage Example:

final users = JsonList<UserModel>('users');
users.value = [
  {'name': 'John', 'age': 30},
  {'name': 'Jane', 'age': 25}
]; // Automatically deserializes to List<UserModel>

print(users[0]['name']); // 'John'
print(users.length);     // 2

See also:

Inheritance

Constructors

JsonList(String fieldName)
Creates a new JsonList field with the specified field name.

Properties

error String?
An error message associated with this field, if any.
getter/setter pairinherited
fieldName String
The name of this field as it appears in JSON data.
finalinherited
hasError bool
Returns true if this field has an error message.
no setterinherited
hashCode int
Returns the hash code for this field.
no setterinherited
hasInformation bool
Returns true if this field has an informational message.
no setterinherited
hasWarning bool
Returns true if this field has a warning message.
no setterinherited
information String?
An informational message associated with this field, if any.
getter/setter pairinherited
isNotNull bool
Returns true if the raw value of this field is not null.
no setterinherited
isNull bool
Returns true if the raw value of this field is null.
no setterinherited
rawValue List<T>?
The raw, unprocessed value stored in this field.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value List<T>
Returns the list of model objects.
getter/setter pairoverride
warning String?
A warning message associated with this field, if any.
getter/setter pairinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() List<Map<String, dynamic>>?
Serializes the list of model objects to a JSON array.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
Determines whether this field is equal to another object.
inherited
operator [](int index) → dynamic
Retrieves the model object at the specified index.
operator []=(int index, dynamic value) → void
Sets the model object at the specified index.