Get both size and offset from hive

This commit is contained in:
Ankit Mahato
2023-04-27 06:30:54 +05:30
parent 53c91c3974
commit c95da70c2f

View File

@ -12,14 +12,21 @@ Future<void> openBoxes() async {
await Hive.openBox(kSettingsBox); await Hive.openBox(kSettingsBox);
} }
Size? getInitialSize() { (Size?, Offset?) getInitialSize() {
Size? sz;
Offset? off;
var settingsBox = Hive.box(kSettingsBox); var settingsBox = Hive.box(kSettingsBox);
double? w = settingsBox.get("width") as double?; double? w = settingsBox.get("width") as double?;
double? h = settingsBox.get("height") as double?; double? h = settingsBox.get("height") as double?;
if (w != null && h != null) { if (w != null && h != null) {
return Size(w, h); sz = Size(w, h);
} }
return null; double? dx = settingsBox.get("dx") as double?;
double? dy = settingsBox.get("dy") as double?;
if (dx != null && dy != null) {
off = Offset(dx, dy);
}
return (sz, off);
} }
final hiveHandler = HiveHandler(); final hiveHandler = HiveHandler();