Refactored the code so that DifficultyDropdown
is not longer needed
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user