Creating your own IterableEntity / Iterable2Entity kind
// 1.
@TypeTemplate('List<List<#1>>')
// 2
abstract class MultiListEntity<I extends InvalidEntity, V extends ValidEntity>
extends IterableEntity<I, V> {
// 3
@protected
@optionalTypeArgs
List<List<R>> $primeCollection<R>(List<List<R>> collection) {
final nestedLists = collection.map(List.unmodifiable);
return List.unmodifiable(nestedLists);
}
// 4
@protected
@optionalTypeArgs
Iterable<R> $collectionToIterable<R>(List<List<R>> collection) {
return collection.expand((nestedList) => nestedList);
}
// 5
@protected
@optionalTypeArgs
List<List<R>> $castCollection<S, R>(List<List<S>> source) {
return source.map((nestedList) => nestedList.cast<R>()).toList();
}
// 6
@override
String $description(int index) => 'MultiList item $index';
}Last updated