Add RouteSettings to showCupertinoSheet#178643
Conversation
There was a problem hiding this comment.
Code Review
This pull request successfully adds the RouteSettings parameter to showCupertinoSheet and integrates it into the CupertinoSheetRoute. The accompanying test case effectively validates this new functionality, ensuring that route settings are correctly propagated and observed. The changes are well-implemented and directly address the reported issue.
| void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) => onDidChange(previousRoute!); | ||
|
|
||
| @override | ||
| void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) => | ||
| onDidChange(previousRoute!); | ||
|
|
||
| @override | ||
| void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) => onDidChange(newRoute!); |
There was a problem hiding this comment.
The didPop, didRemove, and didReplace methods in _ClosureNavigatorObserver use the null-assertion operator (!) on previousRoute and newRoute. While the current test scenario might not trigger a null value for previousRoute or newRoute, these methods are general NavigatorObserver callbacks and previousRoute can legitimately be null (e.g., when the last route is popped). Using ! here could lead to runtime errors in other test cases where these routes might be null. It's safer to handle the nullable routes explicitly before passing them to onDidChange.
@override
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (previousRoute != null) {
onDidChange(previousRoute);
}
}
@override
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (previousRoute != null) {
onDidChange(previousRoute);
}
}
@override
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
if (newRoute != null) {
onDidChange(newRoute);
}
}There was a problem hiding this comment.
Looks like we do this same pattern elsewhere.
I'm of the opinion that for this test case it's fine that this would throw an error if the route is null for this case, as it shouldn't be null and it might catch an issue with later PRs.
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
MitchellGoodwin
left a comment
There was a problem hiding this comment.
LGTM. Thank you for putting this together. I will ask around for a second review.
| void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) => onDidChange(previousRoute!); | ||
|
|
||
| @override | ||
| void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) => | ||
| onDidChange(previousRoute!); | ||
|
|
||
| @override | ||
| void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) => onDidChange(newRoute!); |
There was a problem hiding this comment.
Looks like we do this same pattern elsewhere.
I'm of the opinion that for this test case it's fine that this would throw an error if the route is null for this case, as it shouldn't be null and it might catch an issue with later PRs.
| /// The `settings` argument define the settings for this route. See | ||
| /// [RouteSettings] for details. | ||
| /// |
There was a problem hiding this comment.
| /// The `settings` argument define the settings for this route. See | |
| /// [RouteSettings] for details. | |
| /// |
| /// | ||
| /// `showCupertinoSheet` always pushes the [CupertinoSheetRoute] to the root | ||
| /// [Navigator]. This is to ensure the previous route animates correctly. | ||
| /// |
There was a problem hiding this comment.
| /// The route can be configured with an optional `settings`. | |
| /// |
|
Hi! @jonmountjoy Are you able to address the comments above so we can work together to get this landed? This is a great addition and I'm looking forward to it! |
dkwingsmt
left a comment
There was a problem hiding this comment.
LGTM. I applied my suggestions.
This PR adds missing RouteSettings to `showCupertinoSheet` Fixes flutter#178641 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This PR adds missing RouteSettings to
showCupertinoSheetFixes #178641
Pre-launch Checklist
///).