tryRestore method
Attempts to restore a prior session from storage on startup. Returns true
when a remembered token existed and the reconnect succeeded.
Implementation
Future<bool> tryRestore() async {
if (!_settings.rememberToken) return false;
final hub = _settings.hub;
final principal = _settings.principal;
if (hub == null || principal == null) return false;
final String uri;
try {
uri = OmnyShellService.normalizeHubUri(hub).toString();
} on Object {
return false;
}
final token = _settings.tokenFor(uri);
if (token == null) return false;
await login(hub: hub, principal: principal, token: token, remember: true);
return state.value.isConnected;
}