Tiny improvement of RouteSettings display (#114481)

* impl

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

Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>

* Update navigator_test.dart

Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>
This commit is contained in:
fzyzcjy 2022-11-19 03:38:10 +08:00 committed by GitHub
parent 459391708e
commit 98077617bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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].

View File

@ -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>?);