nav.dart 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_spinkit/flutter_spinkit.dart';
  4. import 'package:go_router/go_router.dart';
  5. import 'package:page_transition/page_transition.dart';
  6. import 'package:provider/provider.dart';
  7. import '/backend/schema/structs/index.dart';
  8. import '/auth/custom_auth/custom_auth_user_provider.dart';
  9. import '/main.dart';
  10. import '/flutter_flow/flutter_flow_theme.dart';
  11. import '/flutter_flow/lat_lng.dart';
  12. import '/flutter_flow/place.dart';
  13. import '/flutter_flow/flutter_flow_util.dart';
  14. import 'serialization_util.dart';
  15. import '/index.dart';
  16. export 'package:go_router/go_router.dart';
  17. export 'serialization_util.dart';
  18. const kTransitionInfoKey = '__transition_info__';
  19. GlobalKey<NavigatorState> appNavigatorKey = GlobalKey<NavigatorState>();
  20. const debugRouteLinkMap = {
  21. '/login':
  22. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=login',
  23. '/horecagelegenheidCurrent':
  24. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=horecagelegenheidCurrent',
  25. '/home':
  26. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=home',
  27. '/selectprovinciegemeente':
  28. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=selectprovinciegemeente',
  29. '/pUitgaanPage':
  30. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=PUitgaanPage',
  31. '/event':
  32. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=Event',
  33. '/eventCurrent':
  34. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=EventCurrent',
  35. '/kanwegHorecagelegenhedenOverzicht':
  36. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanwegHorecagelegenhedenOverzicht',
  37. '/horecagelegenhedenOverzichtProvinciePage':
  38. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=HorecagelegenhedenOverzichtProvinciePage',
  39. '/kanwegHorecagelegenhedenOverzichtSortPage':
  40. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanwegHorecagelegenhedenOverzichtSortPage',
  41. '/wachtwoordVergeten':
  42. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=wachtwoordVergeten',
  43. '/favorieten':
  44. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=favorieten',
  45. '/kanweg':
  46. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanweg',
  47. '/favorietenCopy':
  48. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=favorietenCopy',
  49. '/kanwegTestUpload':
  50. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanwegTestUpload',
  51. '/mijnProfiel':
  52. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=mijnProfiel',
  53. '/stadsactiviteitAanmaken':
  54. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=stadsactiviteitAanmaken',
  55. '/kanwegHomeCopy':
  56. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanwegHomeCopy',
  57. '/uitgaansevenementAanmaken':
  58. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=uitgaansevenementAanmaken',
  59. '/kanweghorecagelegenheidCurrentCopy':
  60. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanweghorecagelegenheidCurrentCopy',
  61. '/horecagelegenhedenOverzichtCurrent':
  62. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=horecagelegenhedenOverzichtCurrent',
  63. '/kanwegHorecagelegenhedenOverzichtCopy3Copy':
  64. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=kanwegHorecagelegenhedenOverzichtCopy3Copy'
  65. };
  66. class AppStateNotifier extends ChangeNotifier {
  67. AppStateNotifier._();
  68. static AppStateNotifier? _instance;
  69. static AppStateNotifier get instance => _instance ??= AppStateNotifier._();
  70. UitgaanskrantAuthUser? initialUser;
  71. UitgaanskrantAuthUser? user;
  72. bool showSplashImage = true;
  73. String? _redirectLocation;
  74. /// Determines whether the app will refresh and build again when a sign
  75. /// in or sign out happens. This is useful when the app is launched or
  76. /// on an unexpected logout. However, this must be turned off when we
  77. /// intend to sign in/out and then navigate or perform any actions after.
  78. /// Otherwise, this will trigger a refresh and interrupt the action(s).
  79. bool notifyOnAuthChange = true;
  80. bool get loading => user == null || showSplashImage;
  81. bool get loggedIn => user?.loggedIn ?? false;
  82. bool get initiallyLoggedIn => initialUser?.loggedIn ?? false;
  83. bool get shouldRedirect => loggedIn && _redirectLocation != null;
  84. String getRedirectLocation() => _redirectLocation!;
  85. bool hasRedirect() => _redirectLocation != null;
  86. void setRedirectLocationIfUnset(String loc) => _redirectLocation ??= loc;
  87. void clearRedirectLocation() => _redirectLocation = null;
  88. /// Mark as not needing to notify on a sign in / out when we intend
  89. /// to perform subsequent actions (such as navigation) afterwards.
  90. void updateNotifyOnAuthChange(bool notify) => notifyOnAuthChange = notify;
  91. void update(UitgaanskrantAuthUser newUser) {
  92. final shouldUpdate =
  93. user?.uid == null || newUser.uid == null || user?.uid != newUser.uid;
  94. initialUser ??= newUser;
  95. user = newUser;
  96. // Refresh the app on auth change unless explicitly marked otherwise.
  97. // No need to update unless the user has changed.
  98. if (notifyOnAuthChange && shouldUpdate) {
  99. notifyListeners();
  100. }
  101. // Once again mark the notifier as needing to update on auth change
  102. // (in order to catch sign in / out events).
  103. updateNotifyOnAuthChange(true);
  104. }
  105. void stopShowingSplashImage() {
  106. showSplashImage = false;
  107. notifyListeners();
  108. }
  109. }
  110. GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
  111. initialLocation: '/',
  112. debugLogDiagnostics: true,
  113. refreshListenable: appStateNotifier,
  114. navigatorKey: appNavigatorKey,
  115. errorBuilder: (context, state) =>
  116. appStateNotifier.loggedIn ? HomeWidget() : HomeWidget(),
  117. routes: [
  118. FFRoute(
  119. name: '_initialize',
  120. path: '/',
  121. builder: (context, _) =>
  122. appStateNotifier.loggedIn ? HomeWidget() : HomeWidget(),
  123. ),
  124. FFRoute(
  125. name: LoginWidget.routeName,
  126. path: LoginWidget.routePath,
  127. builder: (context, params) => LoginWidget(),
  128. ),
  129. FFRoute(
  130. name: HorecagelegenheidCurrentWidget.routeName,
  131. path: HorecagelegenheidCurrentWidget.routePath,
  132. builder: (context, params) => HorecagelegenheidCurrentWidget(
  133. nid: params.getParam(
  134. 'nid',
  135. ParamType.String,
  136. ),
  137. ),
  138. ),
  139. FFRoute(
  140. name: HomeWidget.routeName,
  141. path: HomeWidget.routePath,
  142. builder: (context, params) => HomeWidget(),
  143. ),
  144. FFRoute(
  145. name: SelectprovinciegemeenteWidget.routeName,
  146. path: SelectprovinciegemeenteWidget.routePath,
  147. builder: (context, params) => SelectprovinciegemeenteWidget(),
  148. ),
  149. FFRoute(
  150. name: PUitgaanPageWidget.routeName,
  151. path: PUitgaanPageWidget.routePath,
  152. builder: (context, params) => PUitgaanPageWidget(
  153. plaats: params.getParam(
  154. 'plaats',
  155. ParamType.String,
  156. ),
  157. services: params.getParam(
  158. 'services',
  159. ParamType.String,
  160. ),
  161. ),
  162. ),
  163. FFRoute(
  164. name: EventWidget.routeName,
  165. path: EventWidget.routePath,
  166. builder: (context, params) => EventWidget(
  167. nid: params.getParam(
  168. 'nid',
  169. ParamType.String,
  170. ),
  171. ),
  172. ),
  173. FFRoute(
  174. name: EventCurrentWidget.routeName,
  175. path: EventCurrentWidget.routePath,
  176. builder: (context, params) => EventCurrentWidget(
  177. nid: params.getParam(
  178. 'nid',
  179. ParamType.String,
  180. ),
  181. horecaid: params.getParam(
  182. 'horecaid',
  183. ParamType.String,
  184. ),
  185. ),
  186. ),
  187. FFRoute(
  188. name: KanwegHorecagelegenhedenOverzichtWidget.routeName,
  189. path: KanwegHorecagelegenhedenOverzichtWidget.routePath,
  190. builder: (context, params) => KanwegHorecagelegenhedenOverzichtWidget(
  191. plaats: params.getParam(
  192. 'plaats',
  193. ParamType.String,
  194. ),
  195. ),
  196. ),
  197. FFRoute(
  198. name: HorecagelegenhedenOverzichtProvinciePageWidget.routeName,
  199. path: HorecagelegenhedenOverzichtProvinciePageWidget.routePath,
  200. builder: (context, params) =>
  201. HorecagelegenhedenOverzichtProvinciePageWidget(
  202. plaats: params.getParam(
  203. 'plaats',
  204. ParamType.String,
  205. ),
  206. ),
  207. ),
  208. FFRoute(
  209. name: KanwegHorecagelegenhedenOverzichtSortPageWidget.routeName,
  210. path: KanwegHorecagelegenhedenOverzichtSortPageWidget.routePath,
  211. builder: (context, params) =>
  212. KanwegHorecagelegenhedenOverzichtSortPageWidget(
  213. plaats: params.getParam(
  214. 'plaats',
  215. ParamType.String,
  216. ),
  217. ),
  218. ),
  219. FFRoute(
  220. name: WachtwoordVergetenWidget.routeName,
  221. path: WachtwoordVergetenWidget.routePath,
  222. builder: (context, params) => WachtwoordVergetenWidget(),
  223. ),
  224. FFRoute(
  225. name: FavorietenWidget.routeName,
  226. path: FavorietenWidget.routePath,
  227. builder: (context, params) => FavorietenWidget(),
  228. ),
  229. FFRoute(
  230. name: KanwegWidget.routeName,
  231. path: KanwegWidget.routePath,
  232. builder: (context, params) => KanwegWidget(),
  233. ),
  234. FFRoute(
  235. name: FavorietenCopyWidget.routeName,
  236. path: FavorietenCopyWidget.routePath,
  237. builder: (context, params) => FavorietenCopyWidget(),
  238. ),
  239. FFRoute(
  240. name: KanwegTestUploadWidget.routeName,
  241. path: KanwegTestUploadWidget.routePath,
  242. builder: (context, params) => KanwegTestUploadWidget(),
  243. ),
  244. FFRoute(
  245. name: MijnProfielWidget.routeName,
  246. path: MijnProfielWidget.routePath,
  247. builder: (context, params) => MijnProfielWidget(),
  248. ),
  249. FFRoute(
  250. name: StadsactiviteitAanmakenWidget.routeName,
  251. path: StadsactiviteitAanmakenWidget.routePath,
  252. builder: (context, params) => StadsactiviteitAanmakenWidget(),
  253. ),
  254. FFRoute(
  255. name: KanwegHomeCopyWidget.routeName,
  256. path: KanwegHomeCopyWidget.routePath,
  257. builder: (context, params) => KanwegHomeCopyWidget(),
  258. ),
  259. FFRoute(
  260. name: UitgaansevenementAanmakenWidget.routeName,
  261. path: UitgaansevenementAanmakenWidget.routePath,
  262. builder: (context, params) => UitgaansevenementAanmakenWidget(
  263. horecagelegenheidNid: params.getParam(
  264. 'horecagelegenheidNid',
  265. ParamType.String,
  266. ),
  267. ),
  268. ),
  269. FFRoute(
  270. name: KanweghorecagelegenheidCurrentCopyWidget.routeName,
  271. path: KanweghorecagelegenheidCurrentCopyWidget.routePath,
  272. builder: (context, params) =>
  273. KanweghorecagelegenheidCurrentCopyWidget(
  274. nid: params.getParam(
  275. 'nid',
  276. ParamType.String,
  277. ),
  278. ),
  279. ),
  280. FFRoute(
  281. name: HorecagelegenhedenOverzichtCurrentWidget.routeName,
  282. path: HorecagelegenhedenOverzichtCurrentWidget.routePath,
  283. builder: (context, params) =>
  284. HorecagelegenhedenOverzichtCurrentWidget(
  285. plaats: params.getParam(
  286. 'plaats',
  287. ParamType.String,
  288. ),
  289. ),
  290. ),
  291. FFRoute(
  292. name: KanwegHorecagelegenhedenOverzichtCopy3CopyWidget.routeName,
  293. path: KanwegHorecagelegenhedenOverzichtCopy3CopyWidget.routePath,
  294. builder: (context, params) =>
  295. KanwegHorecagelegenhedenOverzichtCopy3CopyWidget(
  296. plaats: params.getParam(
  297. 'plaats',
  298. ParamType.String,
  299. ),
  300. ),
  301. )
  302. ].map((r) => r.toRoute(appStateNotifier)).toList(),
  303. observers: ffNavigatorObservers,
  304. );
  305. extension NavParamExtensions on Map<String, String?> {
  306. Map<String, String> get withoutNulls => Map.fromEntries(
  307. entries
  308. .where((e) => e.value != null)
  309. .map((e) => MapEntry(e.key, e.value!)),
  310. );
  311. }
  312. extension NavigationExtensions on BuildContext {
  313. void goNamedAuth(
  314. String name,
  315. bool mounted, {
  316. Map<String, String> pathParameters = const <String, String>{},
  317. Map<String, String> queryParameters = const <String, String>{},
  318. Object? extra,
  319. bool ignoreRedirect = false,
  320. }) =>
  321. !mounted || GoRouter.of(this).shouldRedirect(ignoreRedirect)
  322. ? null
  323. : goNamed(
  324. name,
  325. pathParameters: pathParameters,
  326. queryParameters: queryParameters,
  327. extra: extra,
  328. );
  329. void pushNamedAuth(
  330. String name,
  331. bool mounted, {
  332. Map<String, String> pathParameters = const <String, String>{},
  333. Map<String, String> queryParameters = const <String, String>{},
  334. Object? extra,
  335. bool ignoreRedirect = false,
  336. }) =>
  337. !mounted || GoRouter.of(this).shouldRedirect(ignoreRedirect)
  338. ? null
  339. : pushNamed(
  340. name,
  341. pathParameters: pathParameters,
  342. queryParameters: queryParameters,
  343. extra: extra,
  344. );
  345. void safePop() {
  346. // If there is only one route on the stack, navigate to the initial
  347. // page instead of popping.
  348. if (canPop()) {
  349. pop();
  350. } else {
  351. go('/');
  352. }
  353. }
  354. }
  355. extension GoRouterExtensions on GoRouter {
  356. AppStateNotifier get appState => AppStateNotifier.instance;
  357. void prepareAuthEvent([bool ignoreRedirect = false]) =>
  358. appState.hasRedirect() && !ignoreRedirect
  359. ? null
  360. : appState.updateNotifyOnAuthChange(false);
  361. bool shouldRedirect(bool ignoreRedirect) =>
  362. !ignoreRedirect && appState.hasRedirect();
  363. void clearRedirectLocation() => appState.clearRedirectLocation();
  364. void setRedirectLocationIfUnset(String location) =>
  365. appState.updateNotifyOnAuthChange(false);
  366. }
  367. extension _GoRouterStateExtensions on GoRouterState {
  368. Map<String, dynamic> get extraMap =>
  369. extra != null ? extra as Map<String, dynamic> : {};
  370. Map<String, dynamic> get allParams => <String, dynamic>{}
  371. ..addAll(pathParameters)
  372. ..addAll(uri.queryParameters)
  373. ..addAll(extraMap);
  374. TransitionInfo get transitionInfo => extraMap.containsKey(kTransitionInfoKey)
  375. ? extraMap[kTransitionInfoKey] as TransitionInfo
  376. : TransitionInfo.appDefault();
  377. }
  378. class FFParameters {
  379. FFParameters(this.state, [this.asyncParams = const {}]);
  380. final GoRouterState state;
  381. final Map<String, Future<dynamic> Function(String)> asyncParams;
  382. Map<String, dynamic> futureParamValues = {};
  383. // Parameters are empty if the params map is empty or if the only parameter
  384. // present is the special extra parameter reserved for the transition info.
  385. bool get isEmpty =>
  386. state.allParams.isEmpty ||
  387. (state.allParams.length == 1 &&
  388. state.extraMap.containsKey(kTransitionInfoKey));
  389. bool isAsyncParam(MapEntry<String, dynamic> param) =>
  390. asyncParams.containsKey(param.key) && param.value is String;
  391. bool get hasFutures => state.allParams.entries.any(isAsyncParam);
  392. Future<bool> completeFutures() => Future.wait(
  393. state.allParams.entries.where(isAsyncParam).map(
  394. (param) async {
  395. final doc = await asyncParams[param.key]!(param.value)
  396. .onError((_, __) => null);
  397. if (doc != null) {
  398. futureParamValues[param.key] = doc;
  399. return true;
  400. }
  401. return false;
  402. },
  403. ),
  404. ).onError((_, __) => [false]).then((v) => v.every((e) => e));
  405. dynamic getParam<T>(
  406. String paramName,
  407. ParamType type, {
  408. bool isList = false,
  409. StructBuilder<T>? structBuilder,
  410. }) {
  411. if (futureParamValues.containsKey(paramName)) {
  412. return futureParamValues[paramName];
  413. }
  414. if (!state.allParams.containsKey(paramName)) {
  415. return null;
  416. }
  417. final param = state.allParams[paramName];
  418. // Got parameter from `extras`, so just directly return it.
  419. if (param is! String) {
  420. return param;
  421. }
  422. // Return serialized value.
  423. return deserializeParam<T>(
  424. param,
  425. type,
  426. isList,
  427. structBuilder: structBuilder,
  428. );
  429. }
  430. }
  431. class FFRoute {
  432. const FFRoute({
  433. required this.name,
  434. required this.path,
  435. required this.builder,
  436. this.requireAuth = false,
  437. this.asyncParams = const {},
  438. this.routes = const [],
  439. });
  440. final String name;
  441. final String path;
  442. final bool requireAuth;
  443. final Map<String, Future<dynamic> Function(String)> asyncParams;
  444. final Widget Function(BuildContext, FFParameters) builder;
  445. final List<GoRoute> routes;
  446. GoRoute toRoute(AppStateNotifier appStateNotifier) => GoRoute(
  447. name: name,
  448. path: path,
  449. redirect: (context, state) {
  450. if (appStateNotifier.shouldRedirect) {
  451. final redirectLocation = appStateNotifier.getRedirectLocation();
  452. appStateNotifier.clearRedirectLocation();
  453. return redirectLocation;
  454. }
  455. if (requireAuth && !appStateNotifier.loggedIn) {
  456. appStateNotifier.setRedirectLocationIfUnset(state.uri.toString());
  457. return '/home';
  458. }
  459. return null;
  460. },
  461. pageBuilder: (context, state) {
  462. fixStatusBarOniOS16AndBelow(context);
  463. final ffParams = FFParameters(state, asyncParams);
  464. final page = ffParams.hasFutures
  465. ? FutureBuilder(
  466. future: ffParams.completeFutures(),
  467. builder: (context, _) => builder(context, ffParams),
  468. )
  469. : builder(context, ffParams);
  470. final child = appStateNotifier.loading
  471. ? Center(
  472. child: SizedBox(
  473. width: 80.0,
  474. height: 80.0,
  475. child: SpinKitFadingCircle(
  476. color: FlutterFlowTheme.of(context).primary,
  477. size: 80.0,
  478. ),
  479. ),
  480. )
  481. : page;
  482. final transitionInfo = state.transitionInfo;
  483. return transitionInfo.hasTransition
  484. ? CustomTransitionPage(
  485. key: state.pageKey,
  486. name: state.name,
  487. child: child,
  488. transitionDuration: transitionInfo.duration,
  489. transitionsBuilder:
  490. (context, animation, secondaryAnimation, child) =>
  491. PageTransition(
  492. type: transitionInfo.transitionType,
  493. duration: transitionInfo.duration,
  494. reverseDuration: transitionInfo.duration,
  495. alignment: transitionInfo.alignment,
  496. child: child,
  497. ).buildTransitions(
  498. context,
  499. animation,
  500. secondaryAnimation,
  501. child,
  502. ),
  503. )
  504. : MaterialPage(
  505. key: state.pageKey, name: state.name, child: child);
  506. },
  507. routes: routes,
  508. );
  509. }
  510. class TransitionInfo {
  511. const TransitionInfo({
  512. required this.hasTransition,
  513. this.transitionType = PageTransitionType.fade,
  514. this.duration = const Duration(milliseconds: 300),
  515. this.alignment,
  516. });
  517. final bool hasTransition;
  518. final PageTransitionType transitionType;
  519. final Duration duration;
  520. final Alignment? alignment;
  521. static TransitionInfo appDefault() => TransitionInfo(hasTransition: false);
  522. }
  523. class RootPageContext {
  524. const RootPageContext(this.isRootPage, [this.errorRoute]);
  525. final bool isRootPage;
  526. final String? errorRoute;
  527. static bool isInactiveRootPage(BuildContext context) {
  528. final rootPageContext = context.read<RootPageContext?>();
  529. final isRootPage = rootPageContext?.isRootPage ?? false;
  530. final location = GoRouterState.of(context).uri.toString();
  531. return isRootPage &&
  532. location != '/' &&
  533. location != rootPageContext?.errorRoute;
  534. }
  535. static Widget wrap(Widget child, {String? errorRoute}) => Provider.value(
  536. value: RootPageContext(true, errorRoute),
  537. child: child,
  538. );
  539. }
  540. extension GoRouterLocationExtension on GoRouter {
  541. String getCurrentLocation() {
  542. final RouteMatch lastMatch = routerDelegate.currentConfiguration.last;
  543. final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
  544. ? lastMatch.matches
  545. : routerDelegate.currentConfiguration;
  546. return matchList.uri.toString();
  547. }
  548. }