changed ingredient input

This commit is contained in:
SomnusVeritas
2023-10-17 16:37:39 +02:00
parent 263fe00407
commit 16bf7e4cbc
3 changed files with 126 additions and 61 deletions

View File

@@ -10,21 +10,20 @@ class DifficultyDropdown extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<DropdownMenuEntry> dropdownMenuEntryList = DifficultyUtil.difficulties
.map((e) =>
_toDropdownMenuEntry(DifficultyUtil.difficulties.indexOf(e), e))
.toList();
List<DropdownMenuEntry<Difficulty>> dropdownMenuEntryList =
Difficulty.values.map((e) => _toDropdownMenuEntry(e, e.name)).toList();
return DropdownMenu(
return DropdownMenu<Difficulty?>(
dropdownMenuEntries: dropdownMenuEntryList,
onSelected: (value) {
if (onChanged != null) {
onChanged!(value as int);
onChanged!(value?.index ?? -1);
}
},
);
}
DropdownMenuEntry _toDropdownMenuEntry(int index, String text) =>
DropdownMenuEntry(value: index, label: text);
DropdownMenuEntry<Difficulty> _toDropdownMenuEntry(
Difficulty difficulty, String text) =>
DropdownMenuEntry(value: difficulty, label: text);
}