fromJson static method

Translation? fromJson({
  1. required Map<String, dynamic> json,
})

Implementation

static Translation? fromJson({required Map<String, dynamic> json}) {
  if (!json.containsKey('type')) {
    return null;
  }

  final type = TranslationType.values.byName(json['type']);
  switch (type) {
    case TranslationType.simple:
      return SimpleTranslation.fromJson(json: json);
    case TranslationType.plural:
      return PluralTranslation.fromJson(json: json);
    default:
      return null;
  }
}