transform<T> static method

T? transform<T>(
  1. Type t,
  2. String? value
)

Implementation

static T? transform<T>(Type t, String? value) {
  if (value == null) {
    return null;
  }

  bool isNullableType = checkIsNullable<T>();
  if (isNullableType) {
    switch (t.toString()) {
      case "CustomTheme?":
        return CustomTheme.values.asNameMap()[value] as T?;
      case "DateTime?":
        return DateTime.parse(value) as T?;
      default:
        throw Exception('$t 타입에 대한 transform 함수를 추가 해주세요.');
    }
  } else {
    switch (t) {
      case CustomTheme:
        return CustomTheme.values.asNameMap()[value] as T?;
      case DateTime:
        return DateTime.parse(value) as T?;
      default:
        throw Exception('$t 타입에 대한 transform 함수를 추가 해주세요.');
    }
  }
}