fromYaml static method
Parses the size: map of the manifest; null when the section is
absent (S7 not declared).
Implementation
static SizeConfig? fromYaml(dynamic doc) {
if (doc == null) return null;
if (doc is! Map) {
throw FormatException('size: must be a map {native?, web?}');
}
Map<String, String>? sub(String key) {
final v = doc[key];
if (v == null) return null;
if (v is! Map) throw FormatException('size.$key must be a map');
return {
for (final e in v.entries)
if (e.value is String) e.key: e.value,
};
}
final native = sub('native');
final web = sub('web');
return SizeConfig(
nativePackage: native?['package'],
nativeEntry: native?['entry'],
nativeArch: native?['arch'],
// A declared `web:` map defaults `with` to the default target (like
// native's entry): consumers with the with-target at lib/main.dart
// only declare the baseline.
webWith: web == null ? null : (web['with'] ?? defaultWebWith),
webWithout: web?['without'],
);
}