From 304fa82a93612401260c8159e3f117f114e3ab9c Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Thu, 1 Jan 2026 23:14:52 +0100 Subject: [PATCH 1/4] Fixed bug in player selection --- .../widgets/player_selection.dart | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/presentation/widgets/player_selection.dart b/lib/presentation/widgets/player_selection.dart index d497fcd..c7191a4 100644 --- a/lib/presentation/widgets/player_selection.dart +++ b/lib/presentation/widgets/player_selection.dart @@ -12,13 +12,13 @@ import 'package:provider/provider.dart'; class PlayerSelection extends StatefulWidget { final Function(List value) onChanged; - final List availablePlayers; + final List? availablePlayers; final List? initialSelectedPlayers; const PlayerSelection({ super.key, required this.onChanged, - this.availablePlayers = const [], + this.availablePlayers, this.initialSelectedPlayers, }); @@ -56,17 +56,17 @@ class _PlayerSelectionState extends State { if (mounted) { _allPlayersFuture.then((loadedPlayers) { setState(() { - // If a list of available players is provided, use that list. - if (widget.availablePlayers.isNotEmpty) { - widget.availablePlayers.sort((a, b) => a.name.compareTo(b.name)); - allPlayers = [...widget.availablePlayers]; + // If a list of available players is provided (even if empty), use that list. + if (widget.availablePlayers != null) { + widget.availablePlayers!.sort((a, b) => a.name.compareTo(b.name)); + allPlayers = [...widget.availablePlayers!]; suggestedPlayers = [...allPlayers]; if (widget.initialSelectedPlayers != null) { // Ensures that only players available for selection are pre-selected. selectedPlayers = widget.initialSelectedPlayers! .where( - (p) => widget.availablePlayers.any( + (p) => widget.availablePlayers!.any( (available) => available.id == p.id, ), ) @@ -193,11 +193,7 @@ class _PlayerSelectionState extends State { replacement: TopCenteredMessage( icon: Icons.info, title: 'Info', - message: allPlayers.isEmpty - ? 'No players created yet' - : (selectedPlayers.length == allPlayers.length) - ? 'No more players to add' - : 'No players found with that name', + message: _getInfoText(), ), child: ListView.builder( itemCount: suggestedPlayers.length, @@ -273,4 +269,22 @@ class _PlayerSelectionState extends State { ); } } + + /// Determines the appropriate info text to display when no players + /// are available in the suggested players list. + String _getInfoText() { + if (widget.availablePlayers != null && widget.availablePlayers!.isEmpty) { + // Available players list is provided but empty + return 'All players added to the match'; + } else if (allPlayers.isEmpty) { + // No players exist in the database + return 'No players created yet'; + } else if (selectedPlayers.length == allPlayers.length) { + // All players have been selected + return 'No more players to add'; + } else { + // No players match the search query + return 'No players found with that name'; + } + } } -- 2.49.1 From cb7804cf55a66b2e5bc6a9fd367d1256e9f9de29 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Fri, 2 Jan 2026 18:38:13 +0100 Subject: [PATCH 2/4] Fixed Problem with widget state --- .../main_menu/match_view/create_match/create_match_view.dart | 4 +++- lib/presentation/widgets/player_selection.dart | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index a91a45b..9923d7a 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -110,8 +110,10 @@ class _CreateMatchViewState extends State { ]).then((result) async { groupsList = result[0] as List; playerList = result[1] as List; + setState(() { + filteredPlayerList = List.from(playerList); + }); }); - filteredPlayerList = List.from(playerList); } @override diff --git a/lib/presentation/widgets/player_selection.dart b/lib/presentation/widgets/player_selection.dart index c7191a4..112df65 100644 --- a/lib/presentation/widgets/player_selection.dart +++ b/lib/presentation/widgets/player_selection.dart @@ -182,9 +182,6 @@ class _PlayerSelectionState extends State { style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), const SizedBox(height: 10), - /* - - */ Expanded( child: AppSkeleton( enabled: isLoading, -- 2.49.1 From 87856e6548d4a8ed9595d3f752b709ecf081f690 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Fri, 2 Jan 2026 18:41:39 +0100 Subject: [PATCH 3/4] Simplified info texts --- lib/presentation/widgets/player_selection.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/presentation/widgets/player_selection.dart b/lib/presentation/widgets/player_selection.dart index 112df65..e9aacd3 100644 --- a/lib/presentation/widgets/player_selection.dart +++ b/lib/presentation/widgets/player_selection.dart @@ -270,14 +270,13 @@ class _PlayerSelectionState extends State { /// Determines the appropriate info text to display when no players /// are available in the suggested players list. String _getInfoText() { - if (widget.availablePlayers != null && widget.availablePlayers!.isEmpty) { - // Available players list is provided but empty - return 'All players added to the match'; - } else if (allPlayers.isEmpty) { + if (allPlayers.isEmpty) { // No players exist in the database return 'No players created yet'; - } else if (selectedPlayers.length == allPlayers.length) { - // All players have been selected + } else if (selectedPlayers.length == allPlayers.length || + widget.availablePlayers?.isEmpty == true) { + // All players have been selected or + // available players list is provided but empty return 'No more players to add'; } else { // No players match the search query -- 2.49.1 From bdc3453d7fc9072bf8951314e2b8c204d3e8f357 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Fri, 2 Jan 2026 21:20:30 +0100 Subject: [PATCH 4/4] correct spelling mistake --- lib/presentation/widgets/player_selection.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/presentation/widgets/player_selection.dart b/lib/presentation/widgets/player_selection.dart index e9aacd3..6ca6373 100644 --- a/lib/presentation/widgets/player_selection.dart +++ b/lib/presentation/widgets/player_selection.dart @@ -224,7 +224,7 @@ class _PlayerSelectionState extends State { } /// Adds a new player to the database from the search bar input. - /// Shows a snackbar indicating success xfor failure. + /// Shows a snackbar indicating success or failure. /// [context] - BuildContext to show the snackbar. void addNewPlayerFromSearch({required BuildContext context}) async { String playerName = _searchBarController.text.trim(); -- 2.49.1