Skip to content

Commit bbcb994

Browse files
authored
Merge pull request #622 from flow-mn:develop
RC#2 0.16.6
2 parents 91cce22 + be3a8dd commit bbcb994

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

lib/routes/home_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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) {

lib/utils/extensions/go_router.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Ongoing issue about lack of `popUntil`
22
// https://github.com/flutter/flutter/issues/131625
3+
import "package:flutter/widgets.dart";
34
import "package:go_router/go_router.dart";
5+
import "package:logging/logging.dart";
6+
7+
final Logger _log = Logger("GoRouterExt");
48

59
extension 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+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A personal finance managing app
33

44
publish_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

88
environment:
99
sdk: ">=3.10.0 <4.0.0"

0 commit comments

Comments
 (0)