From 7ee14396b1f1f96ed0472b5949ce82a7f9313276 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Nov 2026 15:38:13 +0100 Subject: server: make local variables final (prefer_final_locals) 270 locals across 52 files. Six of them were declared with an unnecessarily nullable type (ModifierDeck? / LootDeckModel?) although the initializer is non-nullable; non-final locals were silently flow-promoted to the initializer's type, but final locals are not, so the nullability is dropped where it was wrong. --- server/lib/core/state/game_save_state.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'server/lib/core/state/game_save_state.dart') diff --git a/server/lib/core/state/game_save_state.dart b/server/lib/core/state/game_save_state.dart index 331b3a8..57ddf30 100644 --- a/server/lib/core/state/game_save_state.dart +++ b/server/lib/core/state/game_save_state.dart @@ -27,7 +27,7 @@ class GameSaveState { } if (data.containsKey('scenarioSectionsAdded')) { - List scenarioSectionsAdded = + final List scenarioSectionsAdded = data['scenarioSectionsAdded'] as List; gameState._scenarioSectionsAdded.clear(); for (final item in scenarioSectionsAdded) { @@ -78,7 +78,7 @@ class GameSaveState { //main list — update existing objects in-place final list = data['currentList'] as List; - List newList = []; + final List newList = []; for (Map item in list) { if (item["noteRow"] == true) { final String itemId = item["id"] as String; @@ -133,10 +133,10 @@ class GameSaveState { // Prototype has the full initialized card set; used only for nr lookups. final proto = MonsterAbilityState(deckName); - List newDrawList = []; - List drawPile = item["drawPile"] as List; + final List newDrawList = []; + final List drawPile = item["drawPile"] as List; for (final cardItem in drawPile) { - int nr = cardItem["nr"]; + final int nr = cardItem["nr"]; for (final card in proto._drawPile.getList()) { if (card.nr == nr) { newDrawList.add(card); @@ -144,9 +144,9 @@ class GameSaveState { } } } - List newDiscardList = []; + final List newDiscardList = []; for (final cardItem in item["discardPile"] as List) { - int nr = cardItem["nr"]; + final int nr = cardItem["nr"]; for (final card in proto._drawPile.getList()) { if (card.nr == nr) { newDiscardList.add(card); @@ -192,7 +192,7 @@ class GameSaveState { } //////elements - Map elementData = data['elementState']; + final Map elementData = data['elementState']; for (final element in Elements.values) { final raw = elementData[element.index.toString()] as int?; final idx = @@ -218,7 +218,7 @@ class GameSaveState { void loadFromDisk(GameState gameState) { //have to call after init or element state overridden - String? data = getIt().read(); + final String? data = getIt().read(); if (data != null) { _savedState = data; load(gameState); -- cgit v1.3.1