ready method
Implementation
Future<void> ready() async {
if (_state.ready) {
return;
}
_prefs ??= await SharedPreferences.getInstance();
final snapshot = _restoreSnapshot();
if (snapshot == null) {
_setState(_state.copyWith(ready: true));
return;
}
if (snapshot.isExpired) {
await _clearCache();
_setState(
_state.copyWith(
ready: true,
session: null,
expiresAt: null,
),
);
return;
}
_cachedToken = snapshot.token;
_setState(
_state.copyWith(
ready: true,
session: snapshot.session,
expiresAt: snapshot.expiresAt,
),
);
}