isometric-tiles icon indicating copy to clipboard operation
isometric-tiles copied to clipboard

Can not render

Open yhojann-cl opened this issue 7 months ago • 0 comments

When try load the sample project flutter says an error on null object:

$ flutter run
...
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _TypeError was thrown building FutureBuilder<void>(dirty, state:
_FutureBuilderState<void>#8f3f3):
Null check operator used on a null value

The relevant error-causing widget was:
  FutureBuilder<void>
  FutureBuilder:file:///home/.../.pub-cache/hosted/pub.dev/flame-1.23.0/lib/src/game/game_widget/game_widget.dart:389:30

When the exception was thrown, this was the stack:
#0      Tileset.computeDrawRect (package:tiled/src/tileset/tileset.dart:211:40)
#1      IsometricTileLayer.cacheTiles (package:flame_tiled/src/renderable_layers/tile_layers/isometric_tile_layer.dart:60:16)
#2      FlameTileLayer.refreshCache (package:flame_tiled/src/renderable_layers/tile_layers/tile_layer.dart:182:5)
#3      RenderableTiledMap._refreshCache (package:flame_tiled/src/renderable_tile_map.dart:401:13)
#4      new RenderableTiledMap (package:flame_tiled/src/renderable_tile_map.dart:67:5)
#5      RenderableTiledMap.fromTiledMap (package:flame_tiled/src/renderable_tile_map.dart:333:12)
<asynchronous suspension>
#6      TiledComponent.load (package:flame_tiled/src/tiled_component.dart:124:7)
<asynchronous suspension>
#7      _Game.onLoad (package:app/main.dart:13:24)
<asynchronous suspension>
#8      FlameGame.load (package:flame/src/game/flame_game.dart:105:5)
<asynchronous suspension>
#9      GameWidgetState.loaderFuture.<anonymous closure> (package:flame/src/game/game_widget/game_widget.dart:194:9)
<asynchronous suspension>
#10     _FutureBuilderState._subscribe.<anonymous closure> (package:flutter/src/widgets/async.dart:641:31)
<asynchronous suspension>

════════════════════════════════════════════════════════════════════════════════════════════════════

The source code of the dart file is:

class _Game extends FlameGame {

    late TiledComponent mapComponent;

    @override
    Future<void> onLoad() async {
        mapComponent = await TiledComponent.load('map_1.tmx', Vector2.all(16));
        add(mapComponent);
    }
}

void main() {
    runApp(GameWidget(game: _Game()));
}

The files are in:

me@pc:~/.../app/assets$ tree
.
├── images
│   ├── 256_base.png
│   └── 256_decor.png
└── tiles
    └── map_1.tmx

In the pubspec.yaml define the assets:

flutter:
  assets:
    - assets/tiles/map_1.tmx
    - assets/images/256_decor.png
    - assets/images/256_base.png

yhojann-cl avatar Mar 13 '25 21:03 yhojann-cl