Marco
a52a50d4d1
Persist theme in sqlite database. A new table was created for this. Add migration to add table for persisted theme
41 lines
847 B
Dart
41 lines
847 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PersistedBrightness {
|
|
final String brightness;
|
|
|
|
PersistedBrightness(this.brightness);
|
|
|
|
factory PersistedBrightness.fromFlutterBrightness(Brightness brightness) {
|
|
var persistedBrightness = "light";
|
|
|
|
if (brightness == Brightness.dark) {
|
|
persistedBrightness = "dark";
|
|
}
|
|
|
|
return PersistedBrightness(persistedBrightness);
|
|
}
|
|
|
|
Brightness toFlutterBrightness() {
|
|
Brightness flutterBrightness = Brightness.light;
|
|
|
|
if (brightness == "dark") {
|
|
flutterBrightness = Brightness.dark;
|
|
}
|
|
|
|
return flutterBrightness;
|
|
}
|
|
|
|
@override
|
|
String toString() => brightness;
|
|
|
|
PersistedBrightness toOpposite() {
|
|
var newBrightness = "light";
|
|
|
|
if (brightness == "light") {
|
|
newBrightness = "dark";
|
|
}
|
|
|
|
return PersistedBrightness(newBrightness);
|
|
}
|
|
}
|