File tree 2 files changed +27
-1
lines changed
catalyst_voices/apps/voices/lib
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ Future<void> _doBootstrapAndRun(BootstrapWidgetBuilder builder) async {
74
74
await _runApp (app);
75
75
}
76
76
77
+ @visibleForTesting
77
78
GoRouter buildAppRouter ({
78
79
String ? initialLocation,
79
80
}) {
@@ -85,6 +86,18 @@ GoRouter buildAppRouter({
85
86
);
86
87
}
87
88
89
+ @visibleForTesting
90
+ Future <void > registerDependencies () async {
91
+ if (! Dependencies .instance.isInitialized) {
92
+ await Dependencies .instance.init ();
93
+ }
94
+ }
95
+
96
+ @visibleForTesting
97
+ Future <void > restartDependencies () async {
98
+ await Dependencies .instance.reset;
99
+ }
100
+
88
101
/// Initializes the application before it can be run. Should setup all
89
102
/// the things which are necessary before the actual app is run,
90
103
/// either via [runApp] or injected into a test environment during
@@ -102,7 +115,7 @@ Future<BootstrapArgs> bootstrap({
102
115
GoRouter .optionURLReflectsImperativeAPIs = true ;
103
116
setPathUrlStrategy ();
104
117
105
- await Dependencies .instance. init ();
118
+ await registerDependencies ();
106
119
107
120
// Key derivation needs to be initialized before it can be used
108
121
await CatalystKeyDerivation .init ();
Original file line number Diff line number Diff line change @@ -10,13 +10,26 @@ import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
10
10
final class Dependencies extends DependencyProvider {
11
11
static final Dependencies instance = Dependencies ._();
12
12
13
+ bool _isInitialized = false ;
14
+
13
15
Dependencies ._();
14
16
15
17
Future <void > init () async {
16
18
DependencyProvider .instance = this ;
17
19
_registerServices ();
18
20
_registerRepositories ();
19
21
_registerBlocsWithDependencies ();
22
+
23
+ _isInitialized = true ;
24
+ }
25
+
26
+ bool get isInitialized => _isInitialized;
27
+
28
+ @override
29
+ Future <void > get reset {
30
+ return super .reset.whenComplete (() {
31
+ _isInitialized = false ;
32
+ });
20
33
}
21
34
22
35
void _registerBlocsWithDependencies () {
You can’t perform that action at this time.
0 commit comments