diff --git a/useragent/lib/screens/server_connection.dart b/useragent/lib/screens/server_connection.dart index 3a407cf..9f8e851 100644 --- a/useragent/lib/screens/server_connection.dart +++ b/useragent/lib/screens/server_connection.dart @@ -15,11 +15,11 @@ class ServerConnectionScreen extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final connectionState = ref.watch(connectionManagerProvider); - if (connectionState.value != null) { - WidgetsBinding.instance.addPostFrameCallback((_) { + ref.listen(connectionManagerProvider, (_, next) { + if (next.value != null && context.mounted) { context.router.replace(const VaultSetupRoute()); - }); - } + } + }); final body = switch (connectionState) { AsyncLoading() => const CircularProgressIndicator(),