22 lines
716 B
Dart
22 lines
716 B
Dart
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
|
import 'package:window_manager/window_manager.dart';
|
||
|
|
|
||
|
|
|
||
|
|
const String kWinWidthKey = 'window_width';
|
||
|
|
const String kWinHeightKey = 'window_height';
|
||
|
|
const String kWinXKey = 'window_x';
|
||
|
|
const String kWinYKey = 'window_y';
|
||
|
|
|
||
|
|
|
||
|
|
Future<void> saveWindowBounds() async {
|
||
|
|
try {
|
||
|
|
final size = await windowManager.getSize();
|
||
|
|
final position = await windowManager.getPosition();
|
||
|
|
final prefs = await SharedPreferences.getInstance();
|
||
|
|
await prefs.setDouble(kWinWidthKey, size.width);
|
||
|
|
await prefs.setDouble(kWinHeightKey, size.height);
|
||
|
|
await prefs.setDouble(kWinXKey, position.dx);
|
||
|
|
await prefs.setDouble(kWinYKey, position.dy);
|
||
|
|
} catch (_) {}
|
||
|
|
}
|