Skip to content

Commit

Permalink
update theme provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier-plessis committed Aug 30, 2024
1 parent ff6cfa5 commit af2bd34
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ part 'theme_mode_controller.g.dart';
@riverpod
class ThemeModeController extends _$ThemeModeController {
@override
ThemeMode build() => ThemeMode.dark;
ThemeMode build() {
return switch (this) {
'light' => ThemeMode.light,
'dark' => ThemeMode.dark,
_ => ThemeMode.dark,
};
}

void setThemeMode(ThemeMode mode) {
state = mode;
}

void toggleThemeMode() {
if (state == ThemeMode.light) {
state = ThemeMode.dark;
} else {
state = ThemeMode.light;
}
state = state == ThemeMode.light ? ThemeMode.dark : ThemeMode.light;
}
}

0 comments on commit af2bd34

Please sign in to comment.