Reputation: 525
I am employing Riverpod for state management via StateNotifierProvider. My switch button just won't enable upon clicking and thus no state changes to effect theme mode switching. I have spent a ton of hours researching similar issues but none like mine as I am not using setState(). I expect the state of the button to change on clicking on dragging but the thumb of the switch just returns to its initial off position. Please help me with what I am doing wrong. Here are snapshots of my main.dart, home_screen.dart, and the theme controller notifier as I am unable to copy and paste my code correctly as advised with 4 spaces.
Upvotes: 0
Views: 1878
Reputation: 631
You need to update the state
(not the _isDark
variable) this way:
toggleTheme(bool value) {
state = value;
_safePrefs;
}
The image is not complete, so I can't see the use of _isDark
variable (Probably nothing). But You shoul be fine now, at least updating the state.
Upvotes: 2