read method
Implementation
Future<TiledMap> read() async {
String data = await rootBundle.loadString(pathFile);
Map<String, dynamic> _result = jsonDecode(data);
_map = TiledMap.fromJson(_result);
if (_map?.tileSets != null) {
await Future.forEach(_map!.tileSets!, (TileSetDetail tileSet) async {
if (tileSet.source != null) {
if (!(tileSet.source!.contains('.json') ||
tileSet.source!.contains('.tsj'))) {
throw Exception('Invalid TileSet source: only supports json files');
}
String data = await rootBundle.loadString(
'$_basePathFile${tileSet.source}',
);
tileSet.updateFromMap(jsonDecode(data));
}
});
}
return Future.value(_map);
}