read method

Future<TiledMap> read()

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!.contains('.json')) {
        throw Exception('Invalid TileSet source: only supports json files');
      }
      String data = await rootBundle.loadString(
        '$_basePathFile${tileSet.source}',
      );
      Map<String, dynamic> _result = jsonDecode(data);
      tileSet.tileSet = TileSet.fromJson(_result);
    });
  }

  return Future.value(_map);
}