TypeAdapterExtension extension

Extension methods that simplify adapting Object? values into strongly typed collections or custom types using Jetleaf's TypeAdapter system.

These helpers provide a convenient way to "upcast" raw dynamic data into proper Dart types.

Example

Object? rawList = [1, 2, 3];
final list = rawList.upcastToList<int>(); // [1, 2, 3]

Object? rawMap = {'a': 1, 'b': 2};
final map = rawMap.upcastToMap<String, int>(); // {a: 1, b: 2}

Object? rawSet = {10, 20, 30};
final set = rawSet.upcastToSet<int>(); // {10, 20, 30}

Object? value = 'hello';
final upper = value.upcast<String>((src) => src.toString().toUpperCase());
// "HELLO"
on

Methods

upcast<T>(T supplier(Object? source)) → T?

Available on Object?, provided by the TypeAdapterExtension extension

Extension methods that simplify adapting Object? values into strongly typed collections or custom types using Jetleaf's TypeAdapter system.
upcastToList<E>() List<E>

Available on Object?, provided by the TypeAdapterExtension extension

A TypeAdapter that adapts a raw Object into a strongly typed List of type E.
upcastToMap<K, V>() Map<K, V>

Available on Object?, provided by the TypeAdapterExtension extension

A TypeAdapter that adapts a raw Object into a strongly typed Map of type K, V.
upcastToSet<E>() Set<E>

Available on Object?, provided by the TypeAdapterExtension extension

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