File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ class _HomePageState extends State<HomePage>
246246 throw "GoRouter is null" ;
247247 }
248248
249- goRouter.go (path);
249+ await goRouter.push (path);
250250
251251 return true ;
252252 } catch (e) {
Original file line number Diff line number Diff line change 11// Ongoing issue about lack of `popUntil`
22// https://github.com/flutter/flutter/issues/131625
3+ import "package:flutter/widgets.dart" ;
34import "package:go_router/go_router.dart" ;
5+ import "package:logging/logging.dart" ;
6+
7+ final Logger _log = Logger ("GoRouterExt" );
48
59extension GoRouterExt on GoRouter {
610 void popUntil (bool Function (GoRoute ) predicate) {
@@ -20,3 +24,29 @@ extension GoRouterExt on GoRouter {
2024 }
2125 }
2226}
27+
28+ extension GoRouterContextExt on BuildContext {
29+ String get location {
30+ final GoRouter router = GoRouter .of (this );
31+
32+ final RouteMatch lastMatch =
33+ router.routerDelegate.currentConfiguration.last;
34+ final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
35+ ? lastMatch.matches
36+ : router.routerDelegate.currentConfiguration;
37+ final String location = matchList.uri.toString ();
38+ return location;
39+ }
40+
41+ void safePush (String path) {
42+ try {
43+ if (location != path) {
44+ push (path);
45+ } else {
46+ _log.fine ("Not navigating to the same path: $path " );
47+ }
48+ } catch (e) {
49+ push (path);
50+ }
51+ }
52+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ description: A personal finance managing app
33
44publish_to : " none" # Remove this line if you wish to publish to pub.dev
55
6- version : " 0.16.6+293 "
6+ version : " 0.16.6+294 "
77
88environment :
99 sdk : " >=3.10.0 <4.0.0"
You can’t perform that action at this time.
0 commit comments