MultiSectionMapping.fromJson constructor
Creates a section mapping from json.
Implementation
MultiSectionMapping.fromJson(List sections, Map<String, Map>? otherMaps,
{/*String|Uri*/ Object? mapUrl}) {
for (var section in sections.cast<Map>()) {
var offset = section['offset'] as Map?;
if (offset == null) throw const FormatException('section missing offset');
var line = offset['line'] as int?;
if (line == null) throw const FormatException('offset missing line');
var column = offset['column'] as int?;
if (column == null) throw const FormatException('offset missing column');
_lineStart.add(line);
_columnStart.add(column);
var url = section['url'] as String?;
var map = section['map'] as Map?;
if (url != null && map != null) {
throw const FormatException(
"section can't use both url and map entries");
} else if (url != null) {
var other = otherMaps?[url];
if (otherMaps == null || other == null) {
throw FormatException(
'section contains refers to $url, but no map was '
'given for it. Make sure a map is passed in "otherMaps"');
}
_maps.add(parseJson(other, otherMaps: otherMaps, mapUrl: url));
} else if (map != null) {
_maps.add(parseJson(map, otherMaps: otherMaps, mapUrl: mapUrl));
} else {
throw const FormatException('section missing url or map');
}
}
if (_lineStart.isEmpty) {
throw const FormatException('expected at least one section');
}
}