Skip to content

Commit b3770d6

Browse files
EArminjonsfshaza2
andauthored
Add breaking change page for completing Navigator behavior (#11684)
_Description of what this PR is changing or adding, and why:_ A breaking change is planned along the PR bellow. _Issues fixed by this PR (if any):_ flutter/flutter#157505 _PRs or commits this PR depends on (if any):_ flutter/flutter#157725 ## Presubmit checklist - [X] This PR is marked as draft with an explanation if not meant to land until a future stable release. - [X] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [X] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [X] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]>
1 parent 4fba795 commit b3770d6

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/content/release/breaking-changes/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ They're sorted by release and listed in alphabetical order:
3434

3535
### Not yet released to stable
3636

37+
* [Deprecate `RouteTransitionRecord.markForRemove`][deprecate-markForRemove]
38+
in favor of `RouteTransitionRecord.markForComplete`
3739
* [Deprecate `WebGoldenComparator`][]
3840
* [Deprecate `TextField.canRequestFocus`][]
3941
* [Deprecate `ThemeData.dialogBackgroundColor` in favor of `DialogThemeData.backgroundColor`][]
@@ -45,6 +47,7 @@ They're sorted by release and listed in alphabetical order:
4547
* [Updated Material 3 progress indicators][]
4648
* [`.flutter-plugins-dependencies` replaces `.flutter-plugins`][]
4749

50+
[deprecate-markForRemove]: /release/breaking-changes/navigator-complete-route
4851
[Deprecate `WebGoldenComparator`]: /release/breaking-changes/web-golden-comparator
4952
[Deprecate `TextField.canRequestFocus`]: /release/breaking-changes/can-request-focus
5053
[Deprecate `ThemeData.dialogBackgroundColor` in favor of `DialogThemeData.backgroundColor`]: /release/breaking-changes/deprecate-themedata-dialogbackgroundcolor
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: When a route is removed from the stack, associated futures must complete
3+
description: >
4+
Before this breaking change, routes created by Navigator and awaited for
5+
results could never complete if the route was removed instead of popped.
6+
---
7+
8+
## Summary
9+
10+
When routes are pushed, developers can await them to be notified when they are
11+
popped. However, this didn't work when they were removed because the associated
12+
future was never completed.
13+
14+
## Context
15+
16+
All Navigator methods that call `remove` had this issue. By using `complete`,
17+
the issue is properly resolved, allowing developers to pass a result.
18+
19+
## Description of change
20+
21+
All Navigator methods have been updated to no longer call `remove` but instead
22+
use `complete`. Context menus are now built from the `contextMenuBuilder`
23+
parameter.
24+
25+
All methods that directly use `complete` now accept an optional `result`
26+
parameter to return it to the associated future. Other methods that indirectly
27+
use `remove` currently return `null`. In the future, we might extend these
28+
methods with an optional callback function to allow developers to handle pop
29+
logic in indirect scenarios (such as `removeUntil`).
30+
31+
Before this PR, methods bellow can't return a result :
32+
```dart
33+
Navigator.of(context).removeRoute(route);
34+
Navigator.of(context).removeRouteBelow(route);
35+
```
36+
37+
After this PR, methods can return a result :
38+
```dart
39+
Navigator.of(context).removeRoute(route, result);
40+
Navigator.of(context).removeRouteBelow(route, result);
41+
```
42+
43+
## Migration guide
44+
45+
If you implemented `RouteTransitionRecord` and used `markForRemove`,
46+
you need to use `markForComplete` instead. `markForRemove` is now deprecated.
47+
48+
For other developers, no changes are required. The navigator continues to work
49+
as expected with new capabilities.
50+
51+
## Timeline
52+
53+
Landed in version: 3.27.0-1.0.pre.39922
54+
In stable release: X.X.X
55+
56+
## References
57+
58+
### API documentation:
59+
60+
* [`RouteTransitionRecord`]({{site.api}}/flutter/widgets/RouteTransitionRecord-class.html)
61+
* [`Navigator`]({{site.api}}/flutter/widgets/Navigator-class.html)
62+
63+
### Relevant issues:
64+
65+
* [removeRoute unresolved future]({{site.repo.flutter}}/issues/157505)
66+
67+
### Relevant PRs:
68+
69+
* [feat: removeRoute now calls didComplete]({{site.repo.flutter}}/pull/157725)

0 commit comments

Comments
 (0)