Skip to content

Commit 7db2ffd

Browse files
committed
♻️ change describe enum to new dart byName method
1 parent 215d46a commit 7db2ffd

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

lib/providers/ThemeController.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//adapted from https://gist.github.com/RodBr/4d6ebfea8b1f9432ff088bec4455e15c#file-main4-dart
22

3-
import 'package:flutter/foundation.dart';
43
import 'package:flutter/material.dart';
54
import 'package:get_storage/get_storage.dart';
65
import '../../notificationUtil/prevent_update_notifs.dart';
@@ -12,16 +11,15 @@ class ThemeController with ChangeNotifier {
1211
set themeMode(ThemeMode? themeMode) {
1312
PreventUpdatingNotifs.setNow();
1413
_themeMode = themeMode;
15-
GetStorage().write('theme', themeMode.toString().split('.')[1]);
14+
GetStorage().write('theme', themeMode.toString().split('.').last);
1615
notifyListeners();
1716
}
1817

1918
ThemeController() {
2019
String themeText =
2120
GetStorage().read('theme') ?? 'light'; //by default, light is selected
2221
try {
23-
_themeMode =
24-
ThemeMode.values.firstWhere((e) => describeEnum(e) == themeText);
22+
_themeMode = ThemeMode.values.byName(themeText);
2523
} catch (e) {
2624
_themeMode = ThemeMode.system;
2725
}

0 commit comments

Comments
 (0)