Skip to content

Commit 42b02d0

Browse files
authored
Use const route for notAnnounced. (#144050)
1 parent 5517316 commit 42b02d0

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

packages/flutter/lib/src/widgets/navigator.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ enum RoutePopDisposition {
138138
/// The type argument `T` is the route's return type, as used by
139139
/// [currentResult], [popped], and [didPop]. The type `void` may be used if the
140140
/// route does not return a value.
141-
abstract class Route<T> {
141+
abstract class Route<T> extends _RoutePlaceholder {
142142
/// Initialize the [Route].
143143
///
144144
/// If the [settings] are not provided, an empty [RouteSettings] object is
@@ -2896,10 +2896,9 @@ enum _RouteLifecycle {
28962896

28972897
typedef _RouteEntryPredicate = bool Function(_RouteEntry entry);
28982898

2899-
class _NotAnnounced extends Route<void> {
2900-
// A placeholder for the lastAnnouncedPreviousRoute, the
2901-
// lastAnnouncedPoppedNextRoute, and the lastAnnouncedNextRoute before any
2902-
// change has been announced.
2899+
/// Placeholder for a route.
2900+
class _RoutePlaceholder {
2901+
const _RoutePlaceholder();
29032902
}
29042903

29052904
class _RouteEntry extends RouteTransitionRecord {
@@ -2937,12 +2936,12 @@ class _RouteEntry extends RouteTransitionRecord {
29372936
/// remove as a result of a page update.
29382937
static const int kDebugPopAttemptLimit = 100;
29392938

2940-
static final Route<dynamic> notAnnounced = _NotAnnounced();
2939+
static const _RoutePlaceholder notAnnounced = _RoutePlaceholder();
29412940

29422941
_RouteLifecycle currentState;
2943-
Route<dynamic>? lastAnnouncedPreviousRoute = notAnnounced; // last argument to Route.didChangePrevious
2944-
WeakReference<Route<dynamic>> lastAnnouncedPoppedNextRoute = WeakReference<Route<dynamic>>(notAnnounced); // last argument to Route.didPopNext
2945-
Route<dynamic>? lastAnnouncedNextRoute = notAnnounced; // last argument to Route.didChangeNext
2942+
_RoutePlaceholder? lastAnnouncedPreviousRoute = notAnnounced; // last argument to Route.didChangePrevious
2943+
WeakReference<_RoutePlaceholder> lastAnnouncedPoppedNextRoute = WeakReference<_RoutePlaceholder>(notAnnounced); // last argument to Route.didPopNext
2944+
_RoutePlaceholder? lastAnnouncedNextRoute = notAnnounced; // last argument to Route.didChangeNext
29462945
int? lastFocusNode; // The last focused semantic node for the route entry.
29472946

29482947
/// Restoration ID to be used for the encapsulating route when restoration is

packages/flutter/test/painting/system_fonts_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ void main() {
4040
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
4141
LeakTesting.settings = LeakTesting.settings.withIgnored(classes: <String>['CurvedAnimation']);
4242

43-
testWidgets('RenderParagraph relayout upon system fonts changes',
44-
// TODO(polina-c): dispose _NotAnnounced, https://github.com/dart-lang/leak_tracker/issues/218 [leaks-to-clean]
45-
experimentalLeakTesting: LeakTesting.settings.withIgnored(classes: <String>['ValueNotifier<String?>', '_NotAnnounced']),
46-
(WidgetTester tester) async {
43+
testWidgets('RenderParagraph relayout upon system fonts changes', (WidgetTester tester) async {
4744
await tester.pumpWidget(
4845
const MaterialApp(
4946
home: Text('text widget'),

0 commit comments

Comments
 (0)