TextFormField cursor params (#24635)
* cursor fields on textformfield * Test pass-through of cursor properties
This commit is contained in:
parent
f14055529b
commit
6901cd4625
@ -95,6 +95,9 @@ class TextFormField extends FormField<String> {
|
|||||||
FormFieldValidator<String> validator,
|
FormFieldValidator<String> validator,
|
||||||
List<TextInputFormatter> inputFormatters,
|
List<TextInputFormatter> inputFormatters,
|
||||||
bool enabled = true,
|
bool enabled = true,
|
||||||
|
double cursorWidth = 2.0,
|
||||||
|
Radius cursorRadius,
|
||||||
|
Color cursorColor,
|
||||||
Brightness keyboardAppearance,
|
Brightness keyboardAppearance,
|
||||||
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
|
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
|
||||||
bool enableInteractiveSelection = true,
|
bool enableInteractiveSelection = true,
|
||||||
@ -141,6 +144,9 @@ class TextFormField extends FormField<String> {
|
|||||||
onSubmitted: onFieldSubmitted,
|
onSubmitted: onFieldSubmitted,
|
||||||
inputFormatters: inputFormatters,
|
inputFormatters: inputFormatters,
|
||||||
enabled: enabled,
|
enabled: enabled,
|
||||||
|
cursorWidth: cursorWidth,
|
||||||
|
cursorRadius: cursorRadius,
|
||||||
|
cursorColor: cursorColor,
|
||||||
scrollPadding: scrollPadding,
|
scrollPadding: scrollPadding,
|
||||||
keyboardAppearance: keyboardAppearance,
|
keyboardAppearance: keyboardAppearance,
|
||||||
enableInteractiveSelection: enableInteractiveSelection,
|
enableInteractiveSelection: enableInteractiveSelection,
|
||||||
|
@ -71,6 +71,34 @@ void main() {
|
|||||||
expect(textFieldWidget.onEditingComplete, onEditingComplete);
|
expect(textFieldWidget.onEditingComplete, onEditingComplete);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes cursor attributes to underlying TextField', (WidgetTester tester) async {
|
||||||
|
const double cursorWidth = 3.14;
|
||||||
|
const Radius cursorRadius = Radius.circular(4);
|
||||||
|
const Color cursorColor = Colors.purple;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
cursorWidth: cursorWidth,
|
||||||
|
cursorRadius: cursorRadius,
|
||||||
|
cursorColor: cursorColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.cursorWidth, cursorWidth);
|
||||||
|
expect(textFieldWidget.cursorRadius, cursorRadius);
|
||||||
|
expect(textFieldWidget.cursorColor, cursorColor);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async {
|
testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async {
|
||||||
bool _called = false;
|
bool _called = false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user