restore method

Future<void> restore()

Restores the saved state. Call it before runApp so the window does not jump once the stored position is available.

Implementation

Future<void> restore() async {
  try {
    if (!await _storage.load()) return;
  } catch (_) {
    // No usable local storage: keep the defaults.
    return;
  }

  _isVisible = _storage.readBool(_visibleKey) ?? _isVisible;
  _isExpanded = _storage.readBool(_expandedKey) ?? _isExpanded;
  final x = _storage.readDouble(_offsetXKey);
  final y = _storage.readDouble(_offsetYKey);
  if (x != null && y != null) _offset = Offset(x, y);
  _notify();
}