toMappable<T> method

T? toMappable<T>({
  1. T? as,
  2. List<Function>? builders,
})

Implementation

T? toMappable<T>({T? as, List<Function>? builders}) {
  final $builders = [
    ...($cast<Mappable>(as)?.builders ?? []),
    ...(builders ?? [])
  ];
  for (final builder in $builders) {
    Mappable.factories.putIfAbsent(builder().runtimeType, () => builder);
  }
  $debugPrint(Mappable.factories);
  final object = toObject<T>(as?.runtimeType);
  if (kDebugMode) $debugPrint(object?.toString());
  for (final builder in $builders) {
    Mappable.factories.remove(builder().runtimeType);
  }
  return object;
}