Bundle.fromArb constructor
Implementation
factory Bundle.fromArb(Map<String, dynamic> arb) {
final bundleItems = Map.fromEntries(
arb.entries.where(
(entry) => !entry.key.startsWith('@@'),
),
);
final bundle = Bundle(
author: arb['@@author'] ?? '',
context: arb['@@context'] ?? '',
lastModified: arb['@@last_modified'] == null
? DateTime.now()
: DateTime.parse(arb['@@last_modified']),
locale: arb['@@locale'] ?? '',
items: {},
);
for (final item in bundleItems.entries) {
if (item.key.startsWith('@')) continue;
final name = item.key;
final value = item.value;
final options = bundleItems['@$name'] ?? <String, dynamic>{};
bundle.items.add(BundleItem(
name: name,
value: value,
description: options['description'] ?? '',
placeholders: options['placeholders'] ?? {},
type: options['type'] ?? '',
));
}
return bundle;
}