mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Fix typos introduced with the TextField.onTap PR, udpated debugFillProperties (#26088)
This commit is contained in:
parent
0d667859c8
commit
dae7e7b9f2
|
@ -83,7 +83,7 @@ class TextField extends StatefulWidget {
|
||||||
/// [TextField.noMaxLength] then only the current length is displayed.
|
/// [TextField.noMaxLength] then only the current length is displayed.
|
||||||
///
|
///
|
||||||
/// After [maxLength] characters have been input, additional input
|
/// After [maxLength] characters have been input, additional input
|
||||||
/// is ignored, unless [maxLengthEnforced] is set to false. The TextField
|
/// is ignored, unless [maxLengthEnforced] is set to false. The text field
|
||||||
/// enforces the length with a [LengthLimitingTextInputFormatter], which is
|
/// enforces the length with a [LengthLimitingTextInputFormatter], which is
|
||||||
/// evaluated after the supplied [inputFormatters], if any. The [maxLength]
|
/// evaluated after the supplied [inputFormatters], if any. The [maxLength]
|
||||||
/// value must be either null or greater than zero.
|
/// value must be either null or greater than zero.
|
||||||
|
@ -173,7 +173,7 @@ class TextField extends StatefulWidget {
|
||||||
/// Requesting the focus will typically cause the keyboard to be shown
|
/// Requesting the focus will typically cause the keyboard to be shown
|
||||||
/// if it's not showing already.
|
/// if it's not showing already.
|
||||||
///
|
///
|
||||||
/// On Android, the user can hide the keyboard - withouth changing the focus -
|
/// On Android, the user can hide the keyboard - without changing the focus -
|
||||||
/// with the system back button. They can restore the keyboard's visibility
|
/// with the system back button. They can restore the keyboard's visibility
|
||||||
/// by tapping on a text field. The user might hide the keyboard and
|
/// by tapping on a text field. The user might hide the keyboard and
|
||||||
/// switch to a physical keyboard, or they might just need to get it
|
/// switch to a physical keyboard, or they might just need to get it
|
||||||
|
@ -244,7 +244,7 @@ class TextField extends StatefulWidget {
|
||||||
/// to [TextField.noMaxLength] then only the current character count is displayed.
|
/// to [TextField.noMaxLength] then only the current character count is displayed.
|
||||||
///
|
///
|
||||||
/// After [maxLength] characters have been input, additional input
|
/// After [maxLength] characters have been input, additional input
|
||||||
/// is ignored, unless [maxLengthEnforced] is set to false. The TextField
|
/// is ignored, unless [maxLengthEnforced] is set to false. The text field
|
||||||
/// enforces the length with a [LengthLimitingTextInputFormatter], which is
|
/// enforces the length with a [LengthLimitingTextInputFormatter], which is
|
||||||
/// evaluated after the supplied [inputFormatters], if any.
|
/// evaluated after the supplied [inputFormatters], if any.
|
||||||
///
|
///
|
||||||
|
@ -262,7 +262,7 @@ class TextField extends StatefulWidget {
|
||||||
///
|
///
|
||||||
/// ## Limitations
|
/// ## Limitations
|
||||||
///
|
///
|
||||||
/// The TextField does not currently count Unicode grapheme clusters (i.e.
|
/// The text field does not currently count Unicode grapheme clusters (i.e.
|
||||||
/// characters visible to the user), it counts Unicode scalar values, which
|
/// characters visible to the user), it counts Unicode scalar values, which
|
||||||
/// leaves out a number of useful possible characters (like many emoji and
|
/// leaves out a number of useful possible characters (like many emoji and
|
||||||
/// composed characters), so this will be inaccurate in the presence of those
|
/// composed characters), so this will be inaccurate in the presence of those
|
||||||
|
@ -315,7 +315,7 @@ class TextField extends StatefulWidget {
|
||||||
/// {@macro flutter.widgets.editableText.inputFormatters}
|
/// {@macro flutter.widgets.editableText.inputFormatters}
|
||||||
final List<TextInputFormatter> inputFormatters;
|
final List<TextInputFormatter> inputFormatters;
|
||||||
|
|
||||||
/// If false the textfield is "disabled": it ignores taps and its
|
/// If false the text field is "disabled": it ignores taps and its
|
||||||
/// [decoration] is rendered in grey.
|
/// [decoration] is rendered in grey.
|
||||||
///
|
///
|
||||||
/// If non-null this property overrides the [decoration]'s
|
/// If non-null this property overrides the [decoration]'s
|
||||||
|
@ -351,24 +351,24 @@ class TextField extends StatefulWidget {
|
||||||
return enableInteractiveSelection ?? !obscureText;
|
return enableInteractiveSelection ?? !obscureText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the user taps on this textfield.
|
/// Called when the user taps on this text field.
|
||||||
///
|
///
|
||||||
/// The textfield builds a [GestureDetector] to handle input events like tap,
|
/// The text field builds a [GestureDetector] to handle input events like tap,
|
||||||
/// to trigger focus requests, to move the caret, adjust the selection, etc.
|
/// to trigger focus requests, to move the caret, adjust the selection, etc.
|
||||||
/// Handling some of those events by wrapping the textfield with a competing
|
/// Handling some of those events by wrapping the text field with a competing
|
||||||
/// GestureDetector is problematic.
|
/// GestureDetector is problematic.
|
||||||
///
|
///
|
||||||
/// To unconditionally handle taps, without interfering with the textfield's
|
/// To unconditionally handle taps, without interfering with the text field's
|
||||||
/// internal gesture detector, provide this callback.
|
/// internal gesture detector, provide this callback.
|
||||||
///
|
///
|
||||||
/// If the textfield is created with [enabled] false, taps will not be
|
/// If the text field is created with [enabled] false, taps will not be
|
||||||
/// recognized.
|
/// recognized.
|
||||||
///
|
///
|
||||||
/// To be notified when the textfield gains or loses the focus, provide a
|
/// To be notified when the text field gains or loses the focus, provide a
|
||||||
/// [focusNode] and add a listener to that.
|
/// [focusNode] and add a listener to that.
|
||||||
///
|
///
|
||||||
/// To listen to arbitrary pointer events without competing with the
|
/// To listen to arbitrary pointer events without competing with the
|
||||||
/// textfield's internal gesture detector, use a [Listener].
|
/// text field's internal gesture detector, use a [Listener].
|
||||||
final GestureTapCallback onTap;
|
final GestureTapCallback onTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -380,16 +380,25 @@ class TextField extends StatefulWidget {
|
||||||
properties.add(DiagnosticsProperty<TextEditingController>('controller', controller, defaultValue: null));
|
properties.add(DiagnosticsProperty<TextEditingController>('controller', controller, defaultValue: null));
|
||||||
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
|
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
|
||||||
properties.add(DiagnosticsProperty<bool>('enabled', enabled, defaultValue: null));
|
properties.add(DiagnosticsProperty<bool>('enabled', enabled, defaultValue: null));
|
||||||
properties.add(DiagnosticsProperty<InputDecoration>('decoration', decoration));
|
properties.add(DiagnosticsProperty<InputDecoration>('decoration', decoration, defaultValue: const InputDecoration()));
|
||||||
properties.add(DiagnosticsProperty<TextInputType>('keyboardType', keyboardType, defaultValue: TextInputType.text));
|
properties.add(DiagnosticsProperty<TextInputType>('keyboardType', keyboardType, defaultValue: TextInputType.text));
|
||||||
properties.add(DiagnosticsProperty<TextStyle>('style', style, defaultValue: null));
|
properties.add(DiagnosticsProperty<TextStyle>('style', style, defaultValue: null));
|
||||||
properties.add(DiagnosticsProperty<bool>('autofocus', autofocus, defaultValue: false));
|
properties.add(DiagnosticsProperty<bool>('autofocus', autofocus, defaultValue: false));
|
||||||
properties.add(DiagnosticsProperty<bool>('obscureText', obscureText, defaultValue: false));
|
properties.add(DiagnosticsProperty<bool>('obscureText', obscureText, defaultValue: false));
|
||||||
properties.add(DiagnosticsProperty<bool>('autocorrect', autocorrect, defaultValue: false));
|
properties.add(DiagnosticsProperty<bool>('autocorrect', autocorrect, defaultValue: true));
|
||||||
properties.add(IntProperty('maxLines', maxLines, defaultValue: 1));
|
properties.add(IntProperty('maxLines', maxLines, defaultValue: 1));
|
||||||
properties.add(IntProperty('maxLength', maxLength, defaultValue: null));
|
properties.add(IntProperty('maxLength', maxLength, defaultValue: null));
|
||||||
properties.add(FlagProperty('maxLengthEnforced', value: maxLengthEnforced, ifTrue: 'max length enforced'));
|
properties.add(FlagProperty('maxLengthEnforced', value: maxLengthEnforced, defaultValue: true, ifFalse: 'maxLength not enforced'));
|
||||||
properties.add(DiagnosticsProperty<GestureTapCallback>('onTap', onTap, defaultValue: false));
|
properties.add(EnumProperty<TextInputAction>('textInputAction', textInputAction, defaultValue: null));
|
||||||
|
properties.add(EnumProperty<TextCapitalization>('textCapitalization', textCapitalization, defaultValue: TextCapitalization.none));
|
||||||
|
properties.add(EnumProperty<TextAlign>('textAlign', textAlign, defaultValue: TextAlign.start));
|
||||||
|
properties.add(EnumProperty<TextDirection>('textDirection', textDirection, defaultValue: null));
|
||||||
|
properties.add(DoubleProperty('cursorWidth', cursorWidth, defaultValue: 2.0));
|
||||||
|
properties.add(DiagnosticsProperty<Radius>('cursorRadius', cursorRadius, defaultValue: null));
|
||||||
|
properties.add(DiagnosticsProperty<Color>('cursorColor', cursorColor, defaultValue: null));
|
||||||
|
properties.add(DiagnosticsProperty<Brightness>('keyboardAppearance', keyboardAppearance, defaultValue: null));
|
||||||
|
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('scrollPadding', scrollPadding, defaultValue: const EdgeInsets.all(20.0)));
|
||||||
|
properties.add(FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4197,4 +4197,69 @@ void main() {
|
||||||
expect(find.byType(CupertinoButton), findsNWidgets(3));
|
expect(find.byType(CupertinoButton), findsNWidgets(3));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets('default TextField debugFillProperties', (WidgetTester tester) async {
|
||||||
|
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||||
|
|
||||||
|
const TextField().debugFillProperties(builder);
|
||||||
|
|
||||||
|
final List<String> description = builder.properties
|
||||||
|
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
|
||||||
|
.map((DiagnosticsNode node) => node.toString()).toList();
|
||||||
|
|
||||||
|
expect(description, <String>[]);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('TextField implements debugFillProperties', (WidgetTester tester) async {
|
||||||
|
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||||
|
|
||||||
|
// Not checking controller, inputFormatters, focusNode
|
||||||
|
const TextField(
|
||||||
|
decoration: InputDecoration(labelText: 'foo'),
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
textCapitalization: TextCapitalization.none,
|
||||||
|
style: TextStyle(color: Color(0xff00ff00)),
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
autofocus: true,
|
||||||
|
obscureText: true,
|
||||||
|
autocorrect: false,
|
||||||
|
maxLines: 10,
|
||||||
|
maxLength: 100,
|
||||||
|
maxLengthEnforced: false,
|
||||||
|
enabled: false,
|
||||||
|
cursorWidth: 1.0,
|
||||||
|
cursorRadius: Radius.zero,
|
||||||
|
cursorColor: Color(0xff00ff00),
|
||||||
|
keyboardAppearance: Brightness.dark,
|
||||||
|
scrollPadding: EdgeInsets.zero,
|
||||||
|
enableInteractiveSelection: false,
|
||||||
|
).debugFillProperties(builder);
|
||||||
|
|
||||||
|
final List<String> description = builder.properties
|
||||||
|
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
|
||||||
|
.map((DiagnosticsNode node) => node.toString()).toList();
|
||||||
|
|
||||||
|
expect(description, <String>[
|
||||||
|
'enabled: false',
|
||||||
|
'decoration: InputDecoration(labelText: "foo")',
|
||||||
|
'style: TextStyle(inherit: true, color: Color(0xff00ff00))',
|
||||||
|
'autofocus: true',
|
||||||
|
'obscureText: true',
|
||||||
|
'autocorrect: false',
|
||||||
|
'maxLines: 10',
|
||||||
|
'maxLength: 100',
|
||||||
|
'maxLength not enforced',
|
||||||
|
'textInputAction: done',
|
||||||
|
'textAlign: end',
|
||||||
|
'textDirection: ltr',
|
||||||
|
'cursorWidth: 1.0',
|
||||||
|
'cursorRadius: Radius.circular(0.0)',
|
||||||
|
'cursorColor: Color(0xff00ff00)',
|
||||||
|
'keyboardAppearance: Brightness.dark',
|
||||||
|
'scrollPadding: EdgeInsets.zero',
|
||||||
|
'selection disabled'
|
||||||
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue