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