fromJsonStringMapIsoList static method
Special case for ISO codes that should be unique for all languages.
e.g. "language_codes": {"en":"nl,fr"} will return
OpenFoodFactsLanguage.DUTCH, OpenFoodFactsLanguage.FRENCH
From a Map<String, String>
in dynamic
's clothing (JsonKey annotation)
Implementation
static List<OpenFoodFactsLanguage>? fromJsonStringMapIsoList(dynamic map) {
if (map == null) {
return null;
}
if (map is! Map<String, dynamic>) {
throw Exception('Expected type: Map<String, String>');
}
final result = <OpenFoodFactsLanguage>[];
for (final value in map.values) {
final String list = value! as String;
if (list.isEmpty) {
continue;
}
final List<String> languages = list.split(',');
for (final String language in languages) {
result.add(LanguageHelper.fromJson(language));
}
}
return result;
}