Handle null cast err

This commit is contained in:
Neeraj Gupta 2023-02-03 12:19:43 +05:30
parent 4ac064e327
commit ab4cab4768
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -127,17 +127,19 @@ class _SessionsPageState extends State<SessionsPage> {
}
Future<void> _fetchActiveSessions() async {
_sessions = await UserService.instance
.getActiveSessions()
.onError((error, stackTrace) {
showToast(context, "Failed to fetch active sessions");
throw error!;
_sessions = await UserService.instance.getActiveSessions().onError((e, s) {
_logger.severe("failed to fetch active sessions", e, s);
if (mounted) {
showToast(context, "Failed to fetch active sessions");
}
});
if (_sessions != null) {
_sessions!.sessions.sort((first, second) {
return second.lastUsedTime.compareTo(first.lastUsedTime);
});
setState(() {});
if (mounted) {
setState(() {});
}
}
}