LocalizedString.from constructor

LocalizedString.from(
  1. Object? source
)

Implementation

factory LocalizedString.from(Object? source) {
  if (source is! Map) return LocalizedString.empty();
  final entries = source.entries.map((e) {
    final key = e.key.toString();
    final value = e.value.toString();
    if (key.isEmpty || value.isEmpty) return null;
    return MapEntry(key, value);
  }).whereType<MapEntry<String, String>>();
  return LocalizedString(Map.fromEntries(entries));
}