Skip to content

Commit

Permalink
Tiny improvement of RouteSettings display (#114481)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
fzyzcjy and chunhtai authored Nov 18, 2022
1 parent 4593917 commit 9807761
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/widgets/navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ class RouteSettings {
final Object? arguments;

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

/// Describes the configuration of a [Route].
Expand Down
10 changes: 10 additions & 0 deletions packages/flutter/test/widgets/navigator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3935,6 +3935,16 @@ void main() {
);
expect(policy, isA<ReadingOrderTraversalPolicy>());
});

group('RouteSettings.toString', () {
test('when name is not null, should have double quote', () {
expect(const RouteSettings(name: '/home').toString(), 'RouteSettings("/home", null)');
});

test('when name is null, should not have double quote', () {
expect(const RouteSettings().toString(), 'RouteSettings(none, null)');
});
});
}

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

0 comments on commit 9807761

Please sign in to comment.