fnotes/lib/persisted_brightness.dart
Marco a52a50d4d1 Persist theme
Persist theme in sqlite database.
A new table was created for this.

Add migration to add table for persisted theme
2024-04-04 20:38:12 +02:00

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);
}
}