fromJson static method

FormatOption fromJson(
  1. Map<String, dynamic> json
)

Implementation

static FormatOption fromJson(Map<String, dynamic> json) {
  final type = EnumToString.fromString(FormatOptions.values, json['type'])!;
  switch (type) {
    case FormatOptions.toInt:
      return ToIntFormatOption.fromJson(json);
    case FormatOptions.toDouble:
      return ToDoubleFormatOption.fromJson(json);
    case FormatOptions.replaceAll:
      return ReplaceAllOption.fromJson(json);
    case FormatOptions.where:
      return WhereOption.fromJson(json);
    case FormatOptions.minutes:
      return PrintMinutesOption.fromJson(json);
    case FormatOptions.hours:
      return PrintHourOption.fromJson(json);
    case FormatOptions.day:
      return PrintDayOption.fromJson(json);
    case FormatOptions.month:
      return PrintMonthOption.fromJson(json);
    case FormatOptions.year:
      return PrintYearOption.fromJson(json);
    case FormatOptions.listMax:
      return ListMaxOption.fromJson(json);
    case FormatOptions.listMin:
      return ListMinOption.fromJson(json);
    case FormatOptions.sortBy:
      return SortByOption.fromJson(json);
    default:
      throw Exception('Unknown format option type');
  }
}