LiteStoreManifest.parse constructor
LiteStoreManifest.parse(
- String yaml
Implementation
factory LiteStoreManifest.parse(String yaml) {
final doc = loadYaml(yaml);
if (doc is! YamlMap) {
throw const FormatException('litestore.yaml must be a map of fields.');
}
String str(String k) => doc[k] == null ? '' : '${doc[k]}'.trim();
List<FeatureRef> refs(String k) {
final v = doc[k];
if (v == null) return const [];
if (v is! YamlList) throw FormatException('"$k" must be a list.');
return [for (final e in v) FeatureRef.parse('$e')];
}
return LiteStoreManifest(
id: str('id'),
name: str('name'),
version: str('version'),
summary: str('summary'),
developer: str('developer'),
category: str('category'),
icon: doc['icon'] == null ? null : str('icon'),
requires: refs('requires'),
optional: refs('optional'),
minBridgeVersion: doc['minBridgeVersion'] is int
? doc['minBridgeVersion'] as int
: 1,
);
}