mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Diagnosticable, not toString, for IOSSystemContextMenuItemDatas (#171028)
Flutter prefers using Diagnosticable instead of toString. See https://github.com/flutter/flutter/issues/169696 and the related PR https://github.com/flutter/flutter/pull/169705. This does the same thing for a few more classes that I missed.
This commit is contained in:
parent
2597ee726b
commit
6b7662649f
@ -2607,7 +2607,7 @@ class _PlatformTextInputControl with TextInputControl {
|
||||
/// * [SystemContextMenu], which wraps this functionality in a widget.
|
||||
/// * [MediaQuery.maybeSupportsShowingSystemContextMenu], which indicates
|
||||
/// whether the system context menu is supported.
|
||||
class SystemContextMenuController with SystemContextMenuClient {
|
||||
class SystemContextMenuController with SystemContextMenuClient, Diagnosticable {
|
||||
/// Creates an instance of [SystemContextMenuController].
|
||||
///
|
||||
/// Not shown until [show] is called.
|
||||
@ -2819,8 +2819,20 @@ class SystemContextMenuController with SystemContextMenuClient {
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SystemContextMenuController(onSystemHide=$onSystemHide, _hiddenBySystem=$_hiddenBySystem, _isVisible=$isVisible, _isDisposed=$_isDisposed)';
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(DiagnosticsProperty<bool>('isVisible', isVisible));
|
||||
properties.add(
|
||||
FlagProperty(
|
||||
'onSystemHide',
|
||||
value: onSystemHide != null,
|
||||
ifTrue: 'callback set',
|
||||
ifFalse: 'callback null',
|
||||
showName: true,
|
||||
),
|
||||
);
|
||||
properties.add(DiagnosticsProperty<bool>('_hiddenBySystem', _hiddenBySystem));
|
||||
properties.add(DiagnosticsProperty<bool>('_isDisposed', _isDisposed));
|
||||
}
|
||||
|
||||
/// Used to release resources when this instance will never be used again.
|
||||
@ -2967,7 +2979,8 @@ final class IOSSystemContextMenuItemDataSelectAll extends IOSSystemContextMenuIt
|
||||
/// * [IOSSystemContextMenuItemLookUp], which performs a similar role but at the
|
||||
/// widget level, where the title can be replaced with a default localized
|
||||
/// value.
|
||||
final class IOSSystemContextMenuItemDataLookUp extends IOSSystemContextMenuItemData {
|
||||
final class IOSSystemContextMenuItemDataLookUp extends IOSSystemContextMenuItemData
|
||||
with Diagnosticable {
|
||||
/// Creates an instance of [IOSSystemContextMenuItemDataLookUp].
|
||||
const IOSSystemContextMenuItemDataLookUp({required this.title});
|
||||
|
||||
@ -2978,8 +2991,9 @@ final class IOSSystemContextMenuItemDataLookUp extends IOSSystemContextMenuItemD
|
||||
String get _jsonType => 'lookUp';
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IOSSystemContextMenuItemDataLookUp(title: $title)';
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(StringProperty('title', title));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2998,7 +3012,8 @@ final class IOSSystemContextMenuItemDataLookUp extends IOSSystemContextMenuItemD
|
||||
/// * [IOSSystemContextMenuItemSearchWeb], which performs a similar role but at
|
||||
/// the widget level, where the title can be replaced with a default localized
|
||||
/// value.
|
||||
final class IOSSystemContextMenuItemDataSearchWeb extends IOSSystemContextMenuItemData {
|
||||
final class IOSSystemContextMenuItemDataSearchWeb extends IOSSystemContextMenuItemData
|
||||
with Diagnosticable {
|
||||
/// Creates an instance of [IOSSystemContextMenuItemDataSearchWeb].
|
||||
const IOSSystemContextMenuItemDataSearchWeb({required this.title});
|
||||
|
||||
@ -3009,8 +3024,9 @@ final class IOSSystemContextMenuItemDataSearchWeb extends IOSSystemContextMenuIt
|
||||
String get _jsonType => 'searchWeb';
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IOSSystemContextMenuItemDataSearchWeb(title: $title)';
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(StringProperty('title', title));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3028,7 +3044,8 @@ final class IOSSystemContextMenuItemDataSearchWeb extends IOSSystemContextMenuIt
|
||||
/// * [IOSSystemContextMenuItemShare], which performs a similar role but at
|
||||
/// the widget level, where the title can be replaced with a default
|
||||
/// localized value.
|
||||
final class IOSSystemContextMenuItemDataShare extends IOSSystemContextMenuItemData {
|
||||
final class IOSSystemContextMenuItemDataShare extends IOSSystemContextMenuItemData
|
||||
with Diagnosticable {
|
||||
/// Creates an instance of [IOSSystemContextMenuItemDataShare].
|
||||
const IOSSystemContextMenuItemDataShare({required this.title});
|
||||
|
||||
@ -3039,8 +3056,9 @@ final class IOSSystemContextMenuItemDataShare extends IOSSystemContextMenuItemDa
|
||||
String get _jsonType => 'share';
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IOSSystemContextMenuItemDataShare(title: $title)';
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(StringProperty('title', title));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1445,6 +1445,51 @@ void main() {
|
||||
expect(client.latestMethodCall, 'didChangeInputControl');
|
||||
});
|
||||
});
|
||||
|
||||
test('SystemContextMenuController debugFillProperties', () {
|
||||
final SystemContextMenuController controller = SystemContextMenuController(onSystemHide: () {});
|
||||
final List<DiagnosticsNode> diagnosticsNodes = controller.toDiagnosticsNode().getProperties();
|
||||
expect(diagnosticsNodes, hasLength(4));
|
||||
expect(diagnosticsNodes[0].name, 'isVisible');
|
||||
expect(diagnosticsNodes[0].value, false);
|
||||
expect(diagnosticsNodes[1].name, 'onSystemHide');
|
||||
expect(diagnosticsNodes[1].value, true);
|
||||
expect(diagnosticsNodes[2].name, '_hiddenBySystem');
|
||||
expect(diagnosticsNodes[2].value, false);
|
||||
expect(diagnosticsNodes[3].name, '_isDisposed');
|
||||
expect(diagnosticsNodes[3].value, false);
|
||||
});
|
||||
|
||||
test('IOSSystemContextMenuItemDataLookUp debugFillProperties', () {
|
||||
const String title = 'my title';
|
||||
const IOSSystemContextMenuItemDataLookUp item = IOSSystemContextMenuItemDataLookUp(
|
||||
title: title,
|
||||
);
|
||||
final List<DiagnosticsNode> diagnosticsNodes = item.toDiagnosticsNode().getProperties();
|
||||
expect(diagnosticsNodes, hasLength(1));
|
||||
expect(diagnosticsNodes.first.name, 'title');
|
||||
expect(diagnosticsNodes.first.value, title);
|
||||
});
|
||||
|
||||
test('IOSSystemContextMenuItemDataSearchWeb debugFillProperties', () {
|
||||
const String title = 'my title';
|
||||
const IOSSystemContextMenuItemDataSearchWeb item = IOSSystemContextMenuItemDataSearchWeb(
|
||||
title: title,
|
||||
);
|
||||
final List<DiagnosticsNode> diagnosticsNodes = item.toDiagnosticsNode().getProperties();
|
||||
expect(diagnosticsNodes, hasLength(1));
|
||||
expect(diagnosticsNodes.first.name, 'title');
|
||||
expect(diagnosticsNodes.first.value, title);
|
||||
});
|
||||
|
||||
test('IOSSystemContextMenuItemDataShare debugFillProperties', () {
|
||||
const String title = 'my title';
|
||||
const IOSSystemContextMenuItemDataShare item = IOSSystemContextMenuItemDataShare(title: title);
|
||||
final List<DiagnosticsNode> diagnosticsNodes = item.toDiagnosticsNode().getProperties();
|
||||
expect(diagnosticsNodes, hasLength(1));
|
||||
expect(diagnosticsNodes.first.name, 'title');
|
||||
expect(diagnosticsNodes.first.value, title);
|
||||
});
|
||||
}
|
||||
|
||||
class FakeTextInputClient with TextInputClient {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user