Refactored the code so that DifficultyDropdown

is not longer needed
This commit is contained in:
SomnusVeritas
2023-10-17 18:17:59 +02:00
parent e69aab7a04
commit 11266b9ab4
3 changed files with 15 additions and 34 deletions

View File

@@ -1,3 +1,5 @@
import 'package:flutter/material.dart';
class DifficultyUtil {
/// Converts lowerCamelCase or UpperCamelCase enum-names to 'normal' Strings
static String getName(Difficulty difficulty) {
@@ -6,6 +8,16 @@ class DifficultyUtil {
name = name[0].toUpperCase() + name.substring(1);
return name;
}
static List<DropdownMenuEntry<Difficulty>> getDropdownList() {
return Difficulty.values
.map((value) => _toDropdownMenuEntry(value))
.toList();
}
static DropdownMenuEntry<Difficulty> _toDropdownMenuEntry(
Difficulty difficulty) =>
DropdownMenuEntry(value: difficulty, label: getName(difficulty));
}
// Only use camelCase or UpperCamelCase for names