setColor method
Sets the provided color. If shouldSave
is true, it will save it in
shared preferences.
This triggers a rebuild of the widgets utilizing the DynamicColorTheme
.
Implementation
Future<void> setColor({
required Color color,
required bool shouldSave,
}) async {
setState(() {
_data = widget.data(color, _isDark);
_color = color;
});
if (shouldSave) {
final SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setInt(_colorSharedPreferencesKey, color.value);
}
}