doTransformToList<T> function

List<T>? doTransformToList<T>(
  1. Object? o,
  2. DataTransformerTo<T>? transformerTo,
  3. DataTransformerToList<T>? transformerToList
)

Implementation

List<T>? doTransformToList<T>(Object? o, DataTransformerTo<T>? transformerTo,
    DataTransformerToList<T>? transformerToList) {
  if (transformerToList != null) {
    return transformerToList(o);
  }

  if (o == null) return [];

  if (o is List) {
    if (o.isEmpty) return [];
    return o
        .map((e) => doTransformTo(e, transformerTo))
        .whereType<T>()
        .toList();
  } else {
    return [doTransformTo(o, transformerTo)].whereType<T>().toList();
  }
}