castListType<T> function

List castListType<T>(
  1. List list,
  2. Type type
)

Implementation

List castListType<T>(List list, Type type) {
  if (list is List<T> && T != dynamic && T != Object) {
    return list;
  } else if (type == String) {
    return list.cast<String>();
  } else if (type == int) {
    return list.cast<int>();
  } else if (type == double) {
    return list.cast<double>();
  } else if (type == num) {
    return list.cast<num>();
  } else if (type == bool) {
    return list.cast<bool>();
  } else if (type == DateTime) {
    return list.cast<DateTime>();
  } else if (type == Duration) {
    return list.cast<Duration>();
  } else if (type == BigInt) {
    return list.cast<BigInt>();
  } else if (type == Uint8List) {
    return list.cast<Uint8List>();
  } else {
    return list;
  }
}