You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/02/07 12:48:00 UTC

[GitHub] [beam] ElessarST commented on a change in pull request #16757: [BEAM-13655] [Playground] Persist the dark/light mode selection

ElessarST commented on a change in pull request #16757:
URL: https://github.com/apache/beam/pull/16757#discussion_r800620651



##########
File path: playground/frontend/lib/config/theme.dart
##########
@@ -22,16 +22,34 @@ import 'package:playground/constants/font_weight.dart';
 import 'package:playground/constants/fonts.dart';
 import 'package:playground/constants/sizes.dart';
 import 'package:provider/provider.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+const kThemeMode = 'theme_mode';
+const kDarkModeString = 'ThemeMode.dark';
 
 class ThemeProvider extends ChangeNotifier {
+  late SharedPreferences _preferences;
   ThemeMode themeMode = ThemeMode.light;
 
+  init() {
+    _setPreferences();
+  }
+
+  _setPreferences() async {
+    _preferences = await SharedPreferences.getInstance();
+    themeMode = _preferences.getString(kThemeMode) == kDarkModeString

Review comment:
       it's better to use `_preferences.getString(kThemeMode) == ThemeMode.dark.toString()` here




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org