Skip to content

Commit

Permalink
fix: NavigatorWillPopMixin not working when pop
Browse files Browse the repository at this point in the history
  • Loading branch information
foxsofter committed Oct 31, 2023
1 parent 4ba31fa commit e8ba50c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.6.4
- fix: NavigatorWillPopMixin not working when pop

## 4.6.3
- fix: push url with query parameter will not get pop result

Expand Down
41 changes: 37 additions & 4 deletions example/lib/src/biz/biz1/flutter3/flutter3.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ class _TestPageState extends State<TestPage> {
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
settings: const RouteSettings(name: 'test'),
builder: (context) => const TestPage()),
);
},
child: const Text(
'Navigator push 2',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
Expand All @@ -302,6 +321,22 @@ class _TestPageState extends State<TestPage> {
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all(Colors.indigo)),
onPressed: () async {
final mctx = await biz.biz1.flutter1.home.push();
ThrioLogger.v(mctx.toString());
},
child: const Text(
'push thrio page',
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
Expand Down Expand Up @@ -380,10 +415,8 @@ class _TestNavigatorPageState extends State<TestNavigatorPage> {

class TestObser extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
}
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {}

@override
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
}
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {}
}
1 change: 1 addition & 0 deletions lib/src/navigator/navigator_will_pop_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mixin NavigatorWillPopMixin<T extends StatefulWidget> on State<T> {
_added = false;
_route?.removeScopedWillPopCallback(onWillPop);
_route = ModalRoute.of(context);
_checkWillPop();
}

void _checkWillPop() {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_thrio
description: Thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.
version: 4.6.3
version: 4.6.4
homepage: https://github.com/flutter-thrio/flutter_thrio

environment:
Expand Down

0 comments on commit e8ba50c

Please sign in to comment.