@@ -4,10 +4,14 @@ import 'package:flutter_it/flutter_it.dart';
44import '../../authentication/authentication_service.dart' ;
55import '../../authentication/view/chat_login_page.dart' ;
66import '../../encryption/view/check_encryption_setup_page.dart' ;
7+ import '../../register_dependencies.dart' ;
8+ import '../app_config.dart' ;
79import 'app.dart' ;
810import 'error_page.dart' ;
911import 'splash_page.dart' ;
1012
13+ final _registrationRestartNotifier = ValueNotifier (UniqueKey ());
14+
1115class WaitForRegistrationPage extends StatefulWidget {
1216 const WaitForRegistrationPage ({
1317 super .key,
@@ -37,34 +41,47 @@ class _WaitForRegistrationPageState extends State<WaitForRegistrationPage> {
3741 }
3842
3943 @override
40- Widget build (BuildContext context) => FutureBuilder (
41- future: _registrationReady,
42- builder: (context, snapshot) => snapshot.hasError
43- ? App (
44- themeMode: ThemeMode .system,
45- lightTheme: widget.lightTheme,
46- darkTheme: widget.darkTheme,
47- highContrastDarkTheme: widget.highContrastDarkTheme,
48- highContrastTheme: widget.highContrastTheme,
49- child: ErrorPage (error: snapshot.error.toString ()),
50- )
51- : snapshot.hasData
52- ? App (
53- lightTheme: widget.lightTheme,
54- darkTheme: widget.darkTheme,
55- highContrastDarkTheme: widget.highContrastDarkTheme,
56- highContrastTheme: widget.highContrastTheme,
57- child: (! di <AuthenticationService >().isLogged)
58- ? const ChatLoginPage ()
59- : const CheckEncryptionSetupPage (),
60- )
61- : App (
62- themeMode: ThemeMode .system,
63- lightTheme: widget.lightTheme,
64- darkTheme: widget.darkTheme,
65- highContrastDarkTheme: widget.highContrastDarkTheme,
66- highContrastTheme: widget.highContrastTheme,
67- child: const SplashPage (),
68- ),
44+ Widget build (BuildContext context) => ValueListenableBuilder (
45+ valueListenable: _registrationRestartNotifier,
46+ builder: (context, value, child) {
47+ return FutureBuilder (
48+ future: _registrationReady,
49+ builder: (context, snapshot) => snapshot.hasError
50+ ? App (
51+ themeMode: ThemeMode .system,
52+ lightTheme: widget.lightTheme,
53+ darkTheme: widget.darkTheme,
54+ highContrastDarkTheme: widget.highContrastDarkTheme,
55+ highContrastTheme: widget.highContrastTheme,
56+ child: ErrorPage (
57+ error: snapshot.error.toString (),
58+ addQuitButton: true ,
59+ onRetry: () {
60+ di.reset (dispose: false );
61+ registerDependencies ();
62+ _registrationRestartNotifier.value = UniqueKey ();
63+ },
64+ ),
65+ )
66+ : snapshot.hasData
67+ ? App (
68+ lightTheme: widget.lightTheme,
69+ darkTheme: widget.darkTheme,
70+ highContrastDarkTheme: widget.highContrastDarkTheme,
71+ highContrastTheme: widget.highContrastTheme,
72+ child: (! di <AuthenticationService >().isLogged)
73+ ? const ChatLoginPage ()
74+ : const CheckEncryptionSetupPage (),
75+ )
76+ : App (
77+ themeMode: ThemeMode .system,
78+ lightTheme: widget.lightTheme,
79+ darkTheme: widget.darkTheme,
80+ highContrastDarkTheme: widget.highContrastDarkTheme,
81+ highContrastTheme: widget.highContrastTheme,
82+ child: const SplashPage (title: Text (AppConfig .appName)),
83+ ),
84+ );
85+ },
6986 );
7087}
0 commit comments