Files
rezepte/lib/widgets/difficulty_dropdown.dart
2023-10-02 20:10:09 +02:00

25 lines
674 B
Dart

import 'package:flutter/material.dart';
import 'package:rezepte/models/recipe.dart';
import '../models/difficulty.dart';
class DifficultyDropdown extends StatelessWidget {
const DifficultyDropdown({super.key});
@override
Widget build(BuildContext context) {
List<DropdownMenuEntry> dropdownMenuEntryList = Difficulty.difficulties
.map(
(e) => _toDropdownMenuEntry(Difficulty.difficulties.indexOf(e), e),
)
.toList();
return DropdownMenu(
dropdownMenuEntries: dropdownMenuEntryList,
);
}
DropdownMenuEntry _toDropdownMenuEntry(int index, String text) =>
DropdownMenuEntry(value: index, label: text);
}