Added name parameters and function doc
This commit is contained in:
@@ -123,10 +123,10 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
.isNotEmpty,
|
.isNotEmpty,
|
||||||
onTrailingButtonPressed: () async {
|
onTrailingButtonPressed: () async {
|
||||||
addNewPlayerFromSearch(
|
addNewPlayerFromSearch(
|
||||||
context,
|
context: context,
|
||||||
_searchBarController,
|
searchBarController: _searchBarController,
|
||||||
db,
|
db: db,
|
||||||
loadPlayerList,
|
loadPlayerList: loadPlayerList,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@@ -338,12 +338,18 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addNewPlayerFromSearch(
|
/// Adds a new player to the database from the search bar input.
|
||||||
context,
|
/// Shows a snackbar indicating success or failure.
|
||||||
searchBarController,
|
/// [context] - BuildContext to show the snackbar.
|
||||||
db,
|
/// [searchBarController] - TextEditingController of the search bar.
|
||||||
loadPlayerList,
|
/// [db] - AppDatabase instance to interact with the database.
|
||||||
) async {
|
/// [loadPlayerList] - Function to reload the player list after adding.
|
||||||
|
void addNewPlayerFromSearch({
|
||||||
|
required BuildContext context,
|
||||||
|
required TextEditingController searchBarController,
|
||||||
|
required AppDatabase db,
|
||||||
|
required Function loadPlayerList,
|
||||||
|
}) async {
|
||||||
String playerName = searchBarController.text.trim();
|
String playerName = searchBarController.text.trim();
|
||||||
bool success = await db.playerDao.addPlayer(player: Player(name: playerName));
|
bool success = await db.playerDao.addPlayer(player: Player(name: playerName));
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user