Unverified Commit abebd340 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Style correctness improvements for toStrings and related fixes (#142485)

Children should be omitted from debugFillProperties (if they really need to be included they should be in debugDescribeChildren, but in general for widgets we don't bother including them since they are eventually included anyway).

toStrings should not contain newlines (or, ideally, should use Diagnosticable).

Also some minor tweaks to match grammar and style guide conventions.
parent 176b439d
...@@ -3252,7 +3252,7 @@ mixin Diagnosticable { ...@@ -3252,7 +3252,7 @@ mixin Diagnosticable {
/// ///
/// Used by [toDiagnosticsNode] and [toString]. /// Used by [toDiagnosticsNode] and [toString].
/// ///
/// Do not add values, that have lifetime shorter than the object. /// Do not add values that have lifetime shorter than the object.
@protected @protected
@mustCallSuper @mustCallSuper
void debugFillProperties(DiagnosticPropertiesBuilder properties) { } void debugFillProperties(DiagnosticPropertiesBuilder properties) { }
......
...@@ -795,7 +795,6 @@ class IconButton extends StatelessWidget { ...@@ -795,7 +795,6 @@ class IconButton extends StatelessWidget {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Widget>('icon', icon, showName: false));
properties.add(StringProperty('tooltip', tooltip, defaultValue: null, quoted: false)); properties.add(StringProperty('tooltip', tooltip, defaultValue: null, quoted: false));
properties.add(ObjectFlagProperty<VoidCallback>('onPressed', onPressed, ifNull: 'disabled')); properties.add(ObjectFlagProperty<VoidCallback>('onPressed', onPressed, ifNull: 'disabled'));
properties.add(ColorProperty('color', color, defaultValue: null)); properties.add(ColorProperty('color', color, defaultValue: null));
......
...@@ -897,10 +897,6 @@ class ListTile extends StatelessWidget { ...@@ -897,10 +897,6 @@ class ListTile extends StatelessWidget {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Widget>('leading', leading, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('title', title, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('subtitle', subtitle, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('trailing', trailing, defaultValue: null));
properties.add(FlagProperty('isThreeLine', value: isThreeLine, ifTrue:'THREE_LINE', ifFalse: 'TWO_LINE', showName: true, defaultValue: false)); properties.add(FlagProperty('isThreeLine', value: isThreeLine, ifTrue:'THREE_LINE', ifFalse: 'TWO_LINE', showName: true, defaultValue: false));
properties.add(FlagProperty('dense', value: dense, ifTrue: 'true', ifFalse: 'false', showName: true)); properties.add(FlagProperty('dense', value: dense, ifTrue: 'true', ifFalse: 'false', showName: true));
properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: null)); properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: null));
......
...@@ -283,7 +283,6 @@ class MenuAnchor extends StatefulWidget { ...@@ -283,7 +283,6 @@ class MenuAnchor extends StatefulWidget {
properties.add(DiagnosticsProperty<MenuStyle?>('style', style)); properties.add(DiagnosticsProperty<MenuStyle?>('style', style));
properties.add(EnumProperty<Clip>('clipBehavior', clipBehavior)); properties.add(EnumProperty<Clip>('clipBehavior', clipBehavior));
properties.add(DiagnosticsProperty<Offset?>('alignmentOffset', alignmentOffset)); properties.add(DiagnosticsProperty<Offset?>('alignmentOffset', alignmentOffset));
properties.add(StringProperty('child', child.toString()));
} }
} }
...@@ -1041,11 +1040,8 @@ class MenuItemButton extends StatefulWidget { ...@@ -1041,11 +1040,8 @@ class MenuItemButton extends StatefulWidget {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(FlagProperty('enabled', value: onPressed != null, ifFalse: 'DISABLED')); properties.add(FlagProperty('enabled', value: onPressed != null, ifFalse: 'DISABLED'));
properties.add(DiagnosticsProperty<String>('child', child.toString()));
properties.add(DiagnosticsProperty<ButtonStyle?>('style', style, defaultValue: null)); properties.add(DiagnosticsProperty<ButtonStyle?>('style', style, defaultValue: null));
properties.add(DiagnosticsProperty<MenuSerializableShortcut?>('shortcut', shortcut, defaultValue: null)); properties.add(DiagnosticsProperty<MenuSerializableShortcut?>('shortcut', shortcut, defaultValue: null));
properties.add(DiagnosticsProperty<Widget?>('leadingIcon', leadingIcon, defaultValue: null));
properties.add(DiagnosticsProperty<Widget?>('trailingIcon', trailingIcon, defaultValue: null));
properties.add(DiagnosticsProperty<FocusNode?>('focusNode', focusNode, defaultValue: null)); properties.add(DiagnosticsProperty<FocusNode?>('focusNode', focusNode, defaultValue: null));
properties.add(EnumProperty<Clip>('clipBehavior', clipBehavior, defaultValue: Clip.none)); properties.add(EnumProperty<Clip>('clipBehavior', clipBehavior, defaultValue: Clip.none));
properties.add(DiagnosticsProperty<MaterialStatesController?>('statesController', statesController, defaultValue: null)); properties.add(DiagnosticsProperty<MaterialStatesController?>('statesController', statesController, defaultValue: null));
...@@ -1802,9 +1798,6 @@ class SubmenuButton extends StatefulWidget { ...@@ -1802,9 +1798,6 @@ class SubmenuButton extends StatefulWidget {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Widget>('leadingIcon', leadingIcon, defaultValue: null));
properties.add(DiagnosticsProperty<String>('child', child.toString()));
properties.add(DiagnosticsProperty<Widget>('trailingIcon', trailingIcon, defaultValue: null));
properties.add(DiagnosticsProperty<FocusNode?>('focusNode', focusNode)); properties.add(DiagnosticsProperty<FocusNode?>('focusNode', focusNode));
properties.add(DiagnosticsProperty<MenuStyle>('menuStyle', menuStyle, defaultValue: null)); properties.add(DiagnosticsProperty<MenuStyle>('menuStyle', menuStyle, defaultValue: null));
properties.add(DiagnosticsProperty<Offset>('alignmentOffset', alignmentOffset)); properties.add(DiagnosticsProperty<Offset>('alignmentOffset', alignmentOffset));
...@@ -3140,7 +3133,6 @@ class _MenuItemLabel extends StatelessWidget { ...@@ -3140,7 +3133,6 @@ class _MenuItemLabel extends StatelessWidget {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<String>('child', child.toString()));
properties.add(DiagnosticsProperty<MenuSerializableShortcut>('shortcut', shortcut, defaultValue: null)); properties.add(DiagnosticsProperty<MenuSerializableShortcut>('shortcut', shortcut, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('hasSubmenu', hasSubmenu)); properties.add(DiagnosticsProperty<bool>('hasSubmenu', hasSubmenu));
properties.add(DiagnosticsProperty<bool>('showDecoration', showDecoration)); properties.add(DiagnosticsProperty<bool>('showDecoration', showDecoration));
......
...@@ -94,7 +94,6 @@ class SegmentedButtonThemeData with Diagnosticable { ...@@ -94,7 +94,6 @@ class SegmentedButtonThemeData with Diagnosticable {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<ButtonStyle>('style', style, defaultValue: null)); properties.add(DiagnosticsProperty<ButtonStyle>('style', style, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('selectedIcon', selectedIcon, defaultValue: null));
} }
} }
......
...@@ -191,7 +191,6 @@ class Tab extends StatelessWidget implements PreferredSizeWidget { ...@@ -191,7 +191,6 @@ class Tab extends StatelessWidget implements PreferredSizeWidget {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(StringProperty('text', text, defaultValue: null)); properties.add(StringProperty('text', text, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('icon', icon, defaultValue: null));
} }
@override @override
......
...@@ -111,6 +111,5 @@ class Placeholder extends StatelessWidget { ...@@ -111,6 +111,5 @@ class Placeholder extends StatelessWidget {
properties.add(DoubleProperty('strokeWidth', strokeWidth, defaultValue: 2.0)); properties.add(DoubleProperty('strokeWidth', strokeWidth, defaultValue: 2.0));
properties.add(DoubleProperty('fallbackWidth', fallbackWidth, defaultValue: 400.0)); properties.add(DoubleProperty('fallbackWidth', fallbackWidth, defaultValue: 400.0));
properties.add(DoubleProperty('fallbackHeight', fallbackHeight, defaultValue: 400.0)); properties.add(DoubleProperty('fallbackHeight', fallbackHeight, defaultValue: 400.0));
properties.add(DiagnosticsProperty<Widget>('child', child, defaultValue: null));
} }
} }
...@@ -2,13 +2,12 @@ ...@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/foundation.dart' show TargetPlatform, defaultTargetPlatform; import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/services.dart' import 'package:flutter/services.dart'
show SpellCheckResults, SpellCheckService, SuggestionSpan, TextEditingValue; show SpellCheckResults, SpellCheckService, SuggestionSpan, TextEditingValue;
import 'editable_text.dart' show EditableTextContextMenuBuilder; import 'editable_text.dart' show EditableTextContextMenuBuilder;
import 'framework.dart' show immutable;
/// Controls how spell check is performed for text input. /// Controls how spell check is performed for text input.
/// ///
...@@ -83,21 +82,19 @@ class SpellCheckConfiguration { ...@@ -83,21 +82,19 @@ class SpellCheckConfiguration {
@override @override
String toString() { String toString() {
return ''' return '${objectRuntimeType(this, 'SpellCheckConfiguration')}('
spell check enabled : $_spellCheckEnabled '${_spellCheckEnabled ? 'enabled' : 'disabled'}, '
spell check service : $spellCheckService 'service: $spellCheckService, '
misspelled text style : $misspelledTextStyle 'text style: $misspelledTextStyle, '
spell check suggestions toolbar builder: $spellCheckSuggestionsToolbarBuilder 'toolbar builder: $spellCheckSuggestionsToolbarBuilder'
''' ')';
.trim();
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
if (identical(this, other)) { if (other.runtimeType != runtimeType) {
return true; return false;
} }
return other is SpellCheckConfiguration return other is SpellCheckConfiguration
&& other.spellCheckService == spellCheckService && other.spellCheckService == spellCheckService
&& other.misspelledTextStyle == misspelledTextStyle && other.misspelledTextStyle == misspelledTextStyle
......
...@@ -2016,10 +2016,6 @@ void main() { ...@@ -2016,10 +2016,6 @@ void main() {
expect( expect(
description, description,
equalsIgnoringHashCodes(<String>[ equalsIgnoringHashCodes(<String>[
'leading: Text',
'title: Text',
'subtitle: Text',
'trailing: Text',
'isThreeLine: THREE_LINE', 'isThreeLine: THREE_LINE',
'dense: true', 'dense: true',
'visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)', 'visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)',
......
...@@ -2356,7 +2356,6 @@ void main() { ...@@ -2356,7 +2356,6 @@ void main() {
description, description,
equalsIgnoringHashCodes( equalsIgnoringHashCodes(
<String>[ <String>[
'child: Text("Menu 0")',
'focusNode: null', 'focusNode: null',
'menuStyle: MenuStyle#00000(backgroundColor: MaterialStatePropertyAll(MaterialColor(primary value: Color(0xff4caf50))), elevation: MaterialStatePropertyAll(20.0), shape: MaterialStatePropertyAll(RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)))', 'menuStyle: MenuStyle#00000(backgroundColor: MaterialStatePropertyAll(MaterialColor(primary value: Color(0xff4caf50))), elevation: MaterialStatePropertyAll(20.0), shape: MaterialStatePropertyAll(RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)))',
'alignmentOffset: null', 'alignmentOffset: null',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment