ListAdapter<E> class

A TypeAdapter that adapts a raw Object into a strongly typed List of type E.

Jetleaf’s conversion service may return values like Iterable<Object>, List<Object>, or ArrayList, which may represent a sequence of values. This adapter ensures that the raw input is converted into a Dart List<E>.

  • If source is null, an empty list is returned.
  • If source is a List, it is directly converted using List<E>.from.
  • If source is an ArrayList, each element is cast and added to a new list.
  • Otherwise, an IllegalArgumentException is thrown.

Example

final adapter = ListAdapter<int>();
final list = adapter.adapt([1, 2, 3]); // [1, 2, 3]

final rawArrayList = ArrayList()..addAll([10, 20, 30]);
final adapted = adapter.adapt(rawArrayList); // [10, 20, 30]

final empty = adapter.adapt(null); // []
Implemented types
Annotations
  • @Generic.new(ListAdapter)

Constructors

ListAdapter()

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

adapt(Object? source) List<E>
A Jetleaf-specific adapter that lifts generic conversion results into strongly-typed values.
override
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