From 55671b7d9c6f058ce187c6a65c506c399c20b9a9 Mon Sep 17 00:00:00 2001 From: foxsofter Date: Thu, 23 May 2024 22:37:51 +0800 Subject: [PATCH] feat: popTo, popUntil support index parameter --- CHANGELOG.md | 4 +++ lib/src/navigator/thrio_navigator.dart | 2 ++ .../navigator/thrio_navigator_implement.dart | 30 ++++++++++++++----- pubspec.yaml | 2 +- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 551fff7..58a15b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.14.0 + +- feat: popTo, popUntil support index parameter + ## 4.13.0 - feat: push support innerURL parameter diff --git a/lib/src/navigator/thrio_navigator.dart b/lib/src/navigator/thrio_navigator.dart index 16e8706..cc45d41 100644 --- a/lib/src/navigator/thrio_navigator.dart +++ b/lib/src/navigator/thrio_navigator.dart @@ -335,10 +335,12 @@ abstract class ThrioNavigator { /// static Future popTo({ required String url, + int? index, bool animated = true, }) => ThrioNavigatorImplement.shared().popTo( url: url, + index: index, animated: animated, ); diff --git a/lib/src/navigator/thrio_navigator_implement.dart b/lib/src/navigator/thrio_navigator_implement.dart index a0158dc..9480d14 100644 --- a/lib/src/navigator/thrio_navigator_implement.dart +++ b/lib/src/navigator/thrio_navigator_implement.dart @@ -906,14 +906,19 @@ class ThrioNavigatorImplement { TParams? params, bool animated = true, }) => - _sendChannel.maybePop(params: params, animated: animated); + _sendChannel.maybePop( + params: params, + animated: animated, + ); Future pop({ TParams? params, bool animated = true, }) { - Future popFuture() => - _sendChannel.pop(params: params, animated: animated); + Future popFuture() => _sendChannel.pop( + params: params, + animated: animated, + ); return _taskQueue.add(popFuture).then((value) => value ?? false); } @@ -921,8 +926,10 @@ class ThrioNavigatorImplement { TParams? params, bool animated = true, }) { - Future popFuture() => - _sendChannel.popFlutter(params: params, animated: animated); + Future popFuture() => _sendChannel.popFlutter( + params: params, + animated: animated, + ); return _taskQueue.add(popFuture).then((value) => value ?? false); } @@ -935,7 +942,10 @@ class ThrioNavigatorImplement { return false; } return _sendChannel.popTo( - url: rootRoute.url, index: rootRoute.index, animated: animated); + url: rootRoute.url, + index: rootRoute.index, + animated: animated, + ); } return _taskQueue.add(popToFuture).then((value) => value ?? false); @@ -943,10 +953,14 @@ class ThrioNavigatorImplement { Future popTo({ required String url, + int? index, bool animated = true, }) { - Future popToFuture() => - _sendChannel.popTo(url: url, animated: animated); + Future popToFuture() => _sendChannel.popTo( + url: url, + index: index ?? 0, + animated: animated, + ); return _taskQueue.add(popToFuture).then((value) => value ?? false); } diff --git a/pubspec.yaml b/pubspec.yaml index f87ab08..d7bcce6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.13.0 +version: 4.14.0 homepage: https://github.com/flutter-thrio/flutter_thrio environment: