Skip to content

Commit 9807761

Browse files
fzyzcjychunhtai
andauthored
Tiny improvement of RouteSettings display (#114481)
* impl * Update packages/flutter/lib/src/widgets/navigator.dart Co-authored-by: chunhtai <[email protected]> * Update navigator_test.dart Co-authored-by: chunhtai <[email protected]>
1 parent 4593917 commit 9807761

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class RouteSettings {
548548
final Object? arguments;
549549

550550
@override
551-
String toString() => '${objectRuntimeType(this, 'RouteSettings')}("$name", $arguments)';
551+
String toString() => '${objectRuntimeType(this, 'RouteSettings')}(${name == null ? 'none' : '"$name"'}, $arguments)';
552552
}
553553

554554
/// Describes the configuration of a [Route].

packages/flutter/test/widgets/navigator_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3935,6 +3935,16 @@ void main() {
39353935
);
39363936
expect(policy, isA<ReadingOrderTraversalPolicy>());
39373937
});
3938+
3939+
group('RouteSettings.toString', () {
3940+
test('when name is not null, should have double quote', () {
3941+
expect(const RouteSettings(name: '/home').toString(), 'RouteSettings("/home", null)');
3942+
});
3943+
3944+
test('when name is null, should not have double quote', () {
3945+
expect(const RouteSettings().toString(), 'RouteSettings(none, null)');
3946+
});
3947+
});
39383948
}
39393949

39403950
typedef AnnouncementCallBack = void Function(Route<dynamic>?);

0 commit comments

Comments
 (0)