Skip to content

Commit

Permalink
refactor: bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
dtscalac committed Sep 19, 2024
1 parent cc4ce45 commit 476fc64
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion catalyst_voices/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
19 changes: 3 additions & 16 deletions catalyst_voices/lib/configs/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> bootstrap([
Future<void> bootstrapAndRun([
BootstrapWidgetBuilder builder = _appBuilder,
]) async {
// There's no need to call WidgetsFlutterBinding.ensureInitialized()
Expand All @@ -44,25 +44,12 @@ Future<void> 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<BootstrapArgs> bootstrapTest() async {
Future<BootstrapArgs> bootstrap() async {
GoRouter.optionURLReflectsImperativeAPIs = true;
setPathUrlStrategy();

Expand Down
2 changes: 1 addition & 1 deletion catalyst_voices/lib/configs/main_dev.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/configs/bootstrap.dart';

void main() async {
await bootstrap();
await bootstrapAndRun();
}
2 changes: 1 addition & 1 deletion catalyst_voices/lib/configs/main_preprod.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/configs/bootstrap.dart';

void main() async {
await bootstrap();
await bootstrapAndRun();
}
2 changes: 1 addition & 1 deletion catalyst_voices/lib/configs/main_prod.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/configs/bootstrap.dart';

void main() async {
await bootstrap();
await bootstrapAndRun();
}
2 changes: 1 addition & 1 deletion catalyst_voices/lib/configs/main_qa.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/configs/bootstrap.dart';

void main() async {
await bootstrap();
await bootstrapAndRun();
}
2 changes: 1 addition & 1 deletion catalyst_voices/lib/configs/main_web.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/configs/bootstrap.dart';

void main() async {
await bootstrap();
await bootstrapAndRun();
}

0 comments on commit 476fc64

Please sign in to comment.