Skip to content

Commit

Permalink
feat: popTo, popUntil support index parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
foxsofter committed May 24, 2024
1 parent 342a6a9 commit 55671b7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.14.0

- feat: popTo, popUntil support index parameter

## 4.13.0

- feat: push support innerURL parameter
Expand Down
2 changes: 2 additions & 0 deletions lib/src/navigator/thrio_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,12 @@ abstract class ThrioNavigator {
///
static Future<bool> popTo({
required String url,
int? index,
bool animated = true,
}) =>
ThrioNavigatorImplement.shared().popTo(
url: url,
index: index,
animated: animated,
);

Expand Down
30 changes: 22 additions & 8 deletions lib/src/navigator/thrio_navigator_implement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -906,23 +906,30 @@ class ThrioNavigatorImplement {
TParams? params,
bool animated = true,
}) =>
_sendChannel.maybePop<TParams>(params: params, animated: animated);
_sendChannel.maybePop<TParams>(
params: params,
animated: animated,
);

Future<bool> pop<TParams>({
TParams? params,
bool animated = true,
}) {
Future<bool> popFuture() =>
_sendChannel.pop<TParams>(params: params, animated: animated);
Future<bool> popFuture() => _sendChannel.pop<TParams>(
params: params,
animated: animated,
);
return _taskQueue.add<bool>(popFuture).then((value) => value ?? false);
}

Future<bool> popFlutter<TParams>({
TParams? params,
bool animated = true,
}) {
Future<bool> popFuture() =>
_sendChannel.popFlutter<TParams>(params: params, animated: animated);
Future<bool> popFuture() => _sendChannel.popFlutter<TParams>(
params: params,
animated: animated,
);
return _taskQueue.add<bool>(popFuture).then((value) => value ?? false);
}

Expand All @@ -935,18 +942,25 @@ 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<bool>(popToFuture).then((value) => value ?? false);
}

Future<bool> popTo({
required String url,
int? index,
bool animated = true,
}) {
Future<bool> popToFuture() =>
_sendChannel.popTo(url: url, animated: animated);
Future<bool> popToFuture() => _sendChannel.popTo(
url: url,
index: index ?? 0,
animated: animated,
);
return _taskQueue.add<bool>(popToFuture).then((value) => value ?? false);
}

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.13.0
version: 4.14.0
homepage: https://github.com/flutter-thrio/flutter_thrio

environment:
Expand Down

0 comments on commit 55671b7

Please sign in to comment.