changed difficulty logic

This commit is contained in:
SomnusVeritas
2023-10-03 23:06:20 +02:00
parent 10463bb61a
commit 518631f37f
4 changed files with 24 additions and 11 deletions

View File

@@ -2,19 +2,26 @@ import 'package:flutter/material.dart';
import '../models/difficulty.dart';
typedef Intcallback = void Function(int);
class DifficultyDropdown extends StatelessWidget {
const DifficultyDropdown({super.key});
const DifficultyDropdown({super.key, this.onChanged});
final Intcallback? onChanged;
@override
Widget build(BuildContext context) {
List<DropdownMenuEntry> dropdownMenuEntryList = Difficulty.difficulties
.map(
(e) => _toDropdownMenuEntry(Difficulty.difficulties.indexOf(e), e),
)
List<DropdownMenuEntry> dropdownMenuEntryList = DifficultyUtil.difficulties
.map((e) =>
_toDropdownMenuEntry(DifficultyUtil.difficulties.indexOf(e), e))
.toList();
return DropdownMenu(
dropdownMenuEntries: dropdownMenuEntryList,
onSelected: (value) {
if (onChanged != null) {
onChanged!(value as int);
}
},
);
}