fromJson static method
Reads back what toJson wrote, or null for a layout this build does not know — a project pinning a newer flutterware than the studio opening it, which is a thing to report rather than to guess at. Guessing would read a CSV as JSON and call the catalog empty.
Implementation
static TranslationCatalog? fromJson(Map<String, Object?> json) {
var name = json['name'] as String? ?? '';
var template = json['template'] as String? ?? 'en';
switch (json[layoutKey]) {
// Absent is not unknown: every declaration written before there was a
// choice described a file per locale, because it was the only thing the
// loader could read.
case null:
case FilePerLocaleCatalog._layout:
return FilePerLocaleCatalog(
name: name,
files: json['files'] as String? ?? '',
template: template,
);
case LocalesPerKeyCatalog._layout:
return LocalesPerKeyCatalog(
name: name,
file: json['file'] as String? ?? '',
template: template,
);
}
return null;
}