Skip to content

Commit

Permalink
Fixed an issue with duplicate icons in game_map.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonarian committed Jul 19, 2022
1 parent 545c335 commit 86d7b7b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/screens/widgets/game_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ class GameMapState extends ConsumerState<GameMap> with SingleTickerProviderState
GlobalKey key = GlobalKey();
final List<String> enemyHexColor = ['#f40C00', '#ff0D00', '#ff0000', '#f00C00'];

late Future<ui.Image> myFuture;

FutureBuilder<ui.Image> imageBuilder(MapObj e) {
FutureBuilder<ui.Image> imageBuilder(MapObj e, Future<ui.Image> future) {
final settings = ref.watch(provider.appSettingsProvider).proximitySetting;
double? distance;
bool flag = false;
Expand All @@ -98,7 +96,7 @@ class GameMapState extends ConsumerState<GameMap> with SingleTickerProviderState
distance < settings.distance;
}
return FutureBuilder<ui.Image>(
future: myFuture,
future: future,
builder: (context, snapshot) {
if (snapshot.hasData) {
if (flag) {
Expand Down Expand Up @@ -238,19 +236,18 @@ class GameMapState extends ConsumerState<GameMap> with SingleTickerProviderState
break;
}
if (e.type == 'aircraft') {
myFuture = ObjectPainter.getUiImage('assets/icons/$assetIcon.png');
return imageBuilder(e);
final future = ObjectPainter.getUiImage('assets/icons/$assetIcon.png');
return imageBuilder(e, future);
} else if (e.type == 'ground_model') {
myFuture = ObjectPainter.getUiImage('assets/icons/$assetIcon.png');
return imageBuilder(e);
final future = ObjectPainter.getUiImage('assets/icons/$assetIcon.png');
return imageBuilder(e, future);
} else if (e.type == 'airfield') {
myFuture = ObjectPainter.getUiImage('assets/icons/$assetIcon.png');
return imageBuilder(e);
final future = ObjectPainter.getUiImage('assets/icons/$assetIcon.png');
return imageBuilder(e, future);
} else {
return const SizedBox();
}
}).toList();

return Stack(
children: columnChildren,
);
Expand Down

0 comments on commit 86d7b7b

Please sign in to comment.