readMap method

  1. @override
Future<TiledMap> readMap()
override

Implementation

@override
Future<TiledMap> readMap() async {
  try {
    TiledMap tiledMap = await _fetchMap();

    await Future.forEach<MapLayer>(
      tiledMap.layers ?? [],
      _fetchLayerImage,
    );
    await Future.forEach<TileSetDetail>(
      tiledMap.tileSets ?? [],
      _loadTileset,
    );
    if (tiledMap.orientation != ORIENTATION_SUPPORTED) {
      throw Exception(
        'Orientation not supported. please use $ORIENTATION_SUPPORTED orientation',
      );
    }
    return Future.value(tiledMap);
  } catch (e) {
    // ignore: avoid_print
    print('(TiledReader) Error: $e');
    return Future.value(TiledMap());
  }
}