From 476fc64d37c3c40ff7d76b39a9a0d937c2319eb7 Mon Sep 17 00:00:00 2001 From: Dominik Toton Date: Thu, 19 Sep 2024 20:32:06 +0200 Subject: [PATCH] refactor: bootstrap --- .../integration_test/app_test.dart | 2 +- catalyst_voices/lib/configs/bootstrap.dart | 19 +++---------------- catalyst_voices/lib/configs/main_dev.dart | 2 +- catalyst_voices/lib/configs/main_preprod.dart | 2 +- catalyst_voices/lib/configs/main_prod.dart | 2 +- catalyst_voices/lib/configs/main_qa.dart | 2 +- catalyst_voices/lib/configs/main_web.dart | 2 +- 7 files changed, 9 insertions(+), 22 deletions(-) diff --git a/catalyst_voices/integration_test/app_test.dart b/catalyst_voices/integration_test/app_test.dart index c1050f0061a..c4814e0e7a3 100644 --- a/catalyst_voices/integration_test/app_test.dart +++ b/catalyst_voices/integration_test/app_test.dart @@ -9,7 +9,7 @@ void main() { group('end-to-end test', () { testWidgets('tap on the floating action button, verify counter', (tester) async { - final args = await bootstrapTest(); + final args = await bootstrap(); await tester.pumpWidget(App(routerConfig: args.routerConfig)); // let the application load await tester.pump(Duration(seconds: 5)); diff --git a/catalyst_voices/lib/configs/bootstrap.dart b/catalyst_voices/lib/configs/bootstrap.dart index d5a05c0580c..7c7fe96df6f 100644 --- a/catalyst_voices/lib/configs/bootstrap.dart +++ b/catalyst_voices/lib/configs/bootstrap.dart @@ -27,7 +27,7 @@ final class BootstrapArgs { // TODO(damian-molinski): Add Isolate.current.addErrorListener // TODO(damian-molinski): Add runZonedGuarded // TODO(damian-molinski): Add Global try-catch -Future bootstrap([ +Future bootstrapAndRun([ BootstrapWidgetBuilder builder = _appBuilder, ]) async { // There's no need to call WidgetsFlutterBinding.ensureInitialized() @@ -44,25 +44,12 @@ Future bootstrap([ ); }; - GoRouter.optionURLReflectsImperativeAPIs = true; - setPathUrlStrategy(); - - final router = AppRouter.init( - guards: const [ - MilestoneGuard(), - ], - ); - - Bloc.observer = AppBlocObserver(); - - await Dependencies.instance.init(); - - final args = BootstrapArgs(routerConfig: router); + final args = await bootstrap(); await _runApp(await builder(args)); } -Future bootstrapTest() async { +Future bootstrap() async { GoRouter.optionURLReflectsImperativeAPIs = true; setPathUrlStrategy(); diff --git a/catalyst_voices/lib/configs/main_dev.dart b/catalyst_voices/lib/configs/main_dev.dart index f24ad0bd1c3..49d48e6de41 100644 --- a/catalyst_voices/lib/configs/main_dev.dart +++ b/catalyst_voices/lib/configs/main_dev.dart @@ -1,5 +1,5 @@ import 'package:catalyst_voices/configs/bootstrap.dart'; void main() async { - await bootstrap(); + await bootstrapAndRun(); } diff --git a/catalyst_voices/lib/configs/main_preprod.dart b/catalyst_voices/lib/configs/main_preprod.dart index f24ad0bd1c3..49d48e6de41 100644 --- a/catalyst_voices/lib/configs/main_preprod.dart +++ b/catalyst_voices/lib/configs/main_preprod.dart @@ -1,5 +1,5 @@ import 'package:catalyst_voices/configs/bootstrap.dart'; void main() async { - await bootstrap(); + await bootstrapAndRun(); } diff --git a/catalyst_voices/lib/configs/main_prod.dart b/catalyst_voices/lib/configs/main_prod.dart index f24ad0bd1c3..49d48e6de41 100644 --- a/catalyst_voices/lib/configs/main_prod.dart +++ b/catalyst_voices/lib/configs/main_prod.dart @@ -1,5 +1,5 @@ import 'package:catalyst_voices/configs/bootstrap.dart'; void main() async { - await bootstrap(); + await bootstrapAndRun(); } diff --git a/catalyst_voices/lib/configs/main_qa.dart b/catalyst_voices/lib/configs/main_qa.dart index f24ad0bd1c3..49d48e6de41 100644 --- a/catalyst_voices/lib/configs/main_qa.dart +++ b/catalyst_voices/lib/configs/main_qa.dart @@ -1,5 +1,5 @@ import 'package:catalyst_voices/configs/bootstrap.dart'; void main() async { - await bootstrap(); + await bootstrapAndRun(); } diff --git a/catalyst_voices/lib/configs/main_web.dart b/catalyst_voices/lib/configs/main_web.dart index f24ad0bd1c3..49d48e6de41 100644 --- a/catalyst_voices/lib/configs/main_web.dart +++ b/catalyst_voices/lib/configs/main_web.dart @@ -1,5 +1,5 @@ import 'package:catalyst_voices/configs/bootstrap.dart'; void main() async { - await bootstrap(); + await bootstrapAndRun(); }