Bearbeiten und Löschen von Matches #171
@@ -110,7 +110,9 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
final bool nameMatches = player.name.toLowerCase().contains(
|
||||
value.toLowerCase(),
|
||||
);
|
||||
final bool isNotSelected = !selectedPlayers.any((p) => p.id == player.id);
|
||||
final bool isNotSelected = !selectedPlayers.any(
|
||||
(p) => p.id == player.id,
|
||||
);
|
||||
return nameMatches && isNotSelected;
|
||||
}).toList();
|
||||
}
|
||||
@@ -224,8 +226,9 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
db.playerDao.getAllPlayers(),
|
||||
Future.delayed(Constants.MINIMUM_SKELETON_DURATION),
|
||||
]).then((results) => results[0] as List<Player>);
|
||||
if (mounted) {
|
||||
|
||||
_allPlayersFuture.then((loadedPlayers) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
// If a list of available players is provided (even if empty), use that list.
|
||||
if (widget.availablePlayers != null) {
|
||||
@@ -249,13 +252,17 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
allPlayers = [...loadedPlayers];
|
||||
if (widget.initialSelectedPlayers != null) {
|
||||
// Excludes already selected players from the suggested players list.
|
||||
suggestedPlayers = loadedPlayers.where((p) => !widget.initialSelectedPlayers!.any((ip) => ip.id == p.id)).toList();
|
||||
suggestedPlayers = loadedPlayers
|
||||
.where(
|
||||
(p) => !widget.initialSelectedPlayers!.any(
|
||||
(ip) => ip.id == p.id,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
// Ensures that only players available for selection are pre-selected.
|
||||
selectedPlayers = widget.initialSelectedPlayers!
|
||||
.where(
|
||||
(p) => allPlayers.any(
|
||||
(available) => available.id == p.id,
|
||||
),
|
||||
(p) => allPlayers.any((available) => available.id == p.id),
|
||||
|
flixcoo marked this conversation as resolved
|
||||
)
|
||||
.toList();
|
||||
} else {
|
||||
@@ -267,7 +274,6 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds a new player to the database from the search bar input.
|
||||
/// Shows a snackbar indicating success or failure.
|
||||
|
||||
Reference in New Issue
Block a user
was geht hier ab? wieso changes?
Da kam dieser Error, den du hattest her. Da habe ich ein if statement entfernt, dadurch hat sich alles verschoben und wird als Änderung markiert. Effektiv habe ich nur ein
if(mounted){...}durch einif(!mounted) return;ersetzt