atlases method

List<(String, Image)> atlases()

Returns a list of all the Atlases that were created for this component.

This method is useful for debugging purposes as it allows developers to check how the tilesets were packed into the atlas.

It returns a record with the Atlas key and its image.

Implementation

List<(String, Image)> atlases() {
  return tileMap.renderableLayers
      .whereType<FlameTileLayer>()
      .where((layer) => layer.tiledAtlas.atlas != null)
      .map((layer) {
        final image = layer.tiledAtlas.atlas;
        final key = layer.tiledAtlas.key;
        return (key, image!);
      })
      .fold<Map<String, (String, Image)>>(
        {},
        (previousValue, element) {
          previousValue.putIfAbsent(element.$1, () => element);
          return previousValue;
        },
      )
      .values
      .toList();
}