Skip to content

Commit

Permalink
move router into locator
Browse files Browse the repository at this point in the history
  • Loading branch information
mocodesmo committed May 2, 2024
1 parent afe4cdb commit 1133a2c
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 201 deletions.
2 changes: 2 additions & 0 deletions lib/locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import 'package:bb_mobile/swap/bloc/watchtxs_bloc.dart';
import 'package:dio/dio.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get_it/get_it.dart';
import 'package:go_router/go_router.dart';

const bbVersion = '0.2.0-1';

Expand Down Expand Up @@ -102,6 +103,7 @@ Future _setupRepositories() async {

Future _setupAppServices() async {
locator.registerSingleton<NavName>(NavName());
locator.registerSingleton<GoRouter>(setupRouter());
final deepLink = DeepLink();
locator.registerSingleton<DeepLink>(deepLink);
locator.registerSingleton<Lighting>(
Expand Down
9 changes: 6 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class BullBitcoinWalletApp extends StatelessWidget {
theme: Themes.lightTheme,
darkTheme: lightingState.dark(),
themeMode: lightingState.mode(),
routerConfig: router,
routerConfig: locator<GoRouter>(),
debugShowCheckedModeBanner: false,
localizationsDelegates: [
localizationDelegate,
Expand Down Expand Up @@ -172,8 +172,11 @@ class _AppLifecycleOverlayState extends State<AppLifecycleOverlay>
super.initState();
WidgetsBinding.instance.addObserver(this);

router.routerDelegate.addListener(() {
final routePath = router.routerDelegate.currentConfiguration.routes
locator<GoRouter>().routerDelegate.addListener(() {
final routePath = locator<GoRouter>()
.routerDelegate
.currentConfiguration
.routes
.map((RouteBase e) => (e as GoRoute).path)
.join();
// print(routePath);
Expand Down
Loading

0 comments on commit 1133a2c

Please sign in to comment.