Add missing parameters in TextFormField
(#127020)
`TextFormField` does not have all the parameters of `TextField`. Added: ```dart UndoHistoryController? undoController, AppPrivateCommandCallback? onAppPrivateCommand, bool? cursorOpacityAnimates, ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ContentInsertionConfiguration? contentInsertionConfiguration, Clip clipBehavior = Clip.hardEdge, bool scribbleEnabled = true, bool canRequestFocus = true, ```
This commit is contained in:
parent
99f792e085
commit
7827a24207
@ -2,6 +2,9 @@
|
|||||||
// 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 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle;
|
||||||
|
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
@ -156,6 +159,16 @@ class TextFormField extends FormField<String> {
|
|||||||
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
|
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
|
||||||
SpellCheckConfiguration? spellCheckConfiguration,
|
SpellCheckConfiguration? spellCheckConfiguration,
|
||||||
TextMagnifierConfiguration? magnifierConfiguration,
|
TextMagnifierConfiguration? magnifierConfiguration,
|
||||||
|
UndoHistoryController? undoController,
|
||||||
|
AppPrivateCommandCallback? onAppPrivateCommand,
|
||||||
|
bool? cursorOpacityAnimates,
|
||||||
|
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
|
||||||
|
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
|
||||||
|
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
|
||||||
|
ContentInsertionConfiguration? contentInsertionConfiguration,
|
||||||
|
Clip clipBehavior = Clip.hardEdge,
|
||||||
|
bool scribbleEnabled = true,
|
||||||
|
bool canRequestFocus = true,
|
||||||
}) : assert(initialValue == null || controller == null),
|
}) : assert(initialValue == null || controller == null),
|
||||||
assert(obscuringCharacter.length == 1),
|
assert(obscuringCharacter.length == 1),
|
||||||
assert(maxLines == null || maxLines > 0),
|
assert(maxLines == null || maxLines > 0),
|
||||||
@ -238,6 +251,16 @@ class TextFormField extends FormField<String> {
|
|||||||
contextMenuBuilder: contextMenuBuilder,
|
contextMenuBuilder: contextMenuBuilder,
|
||||||
spellCheckConfiguration: spellCheckConfiguration,
|
spellCheckConfiguration: spellCheckConfiguration,
|
||||||
magnifierConfiguration: magnifierConfiguration,
|
magnifierConfiguration: magnifierConfiguration,
|
||||||
|
undoController: undoController,
|
||||||
|
onAppPrivateCommand: onAppPrivateCommand,
|
||||||
|
cursorOpacityAnimates: cursorOpacityAnimates,
|
||||||
|
selectionHeightStyle: selectionHeightStyle,
|
||||||
|
selectionWidthStyle: selectionWidthStyle,
|
||||||
|
dragStartBehavior: dragStartBehavior,
|
||||||
|
contentInsertionConfiguration: contentInsertionConfiguration,
|
||||||
|
clipBehavior: clipBehavior,
|
||||||
|
scribbleEnabled: scribbleEnabled,
|
||||||
|
canRequestFocus: canRequestFocus,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// 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 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
@ -1196,6 +1198,227 @@ void main() {
|
|||||||
expect(editableText.magnifierConfiguration, equals(myTextMagnifierConfiguration));
|
expect(editableText.magnifierConfiguration, equals(myTextMagnifierConfiguration));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes undoController to undoController TextField', (WidgetTester tester) async {
|
||||||
|
final UndoHistoryController undoController = UndoHistoryController(value: UndoHistoryValue.empty);
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
undoController: undoController,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.undoController, undoController);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes cursorOpacityAnimates to cursorOpacityAnimates TextField', (WidgetTester tester) async {
|
||||||
|
const bool cursorOpacityAnimates = true;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
cursorOpacityAnimates: cursorOpacityAnimates,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.cursorOpacityAnimates, cursorOpacityAnimates);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes contentInsertionConfiguration to contentInsertionConfiguration TextField', (WidgetTester tester) async {
|
||||||
|
final ContentInsertionConfiguration contentInsertionConfiguration =
|
||||||
|
ContentInsertionConfiguration(onContentInserted: (KeyboardInsertedContent value) {});
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
contentInsertionConfiguration: contentInsertionConfiguration,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.contentInsertionConfiguration, contentInsertionConfiguration);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes clipBehavior to clipBehavior TextField', (WidgetTester tester) async {
|
||||||
|
const Clip clipBehavior = Clip.antiAlias;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
clipBehavior: clipBehavior,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.clipBehavior, clipBehavior);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes scribbleEnabled to scribbleEnabled TextField', (WidgetTester tester) async {
|
||||||
|
const bool scribbleEnabled = false;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
scribbleEnabled: scribbleEnabled,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.scribbleEnabled, scribbleEnabled);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes canRequestFocus to canRequestFocus TextField', (WidgetTester tester) async {
|
||||||
|
const bool canRequestFocus = false;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
canRequestFocus: canRequestFocus,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.canRequestFocus, canRequestFocus);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes onAppPrivateCommand to onAppPrivateCommand TextField', (WidgetTester tester) async {
|
||||||
|
void onAppPrivateCommand(String p0, Map<String, dynamic> p1) {}
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
onAppPrivateCommand: onAppPrivateCommand,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.onAppPrivateCommand, onAppPrivateCommand);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes selectionHeightStyle to selectionHeightStyle TextField', (WidgetTester tester) async {
|
||||||
|
const BoxHeightStyle selectionHeightStyle = BoxHeightStyle.max;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
selectionHeightStyle: selectionHeightStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.selectionHeightStyle, selectionHeightStyle);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes selectionWidthStyle to selectionWidthStyle TextField', (WidgetTester tester) async {
|
||||||
|
const BoxWidthStyle selectionWidthStyle = BoxWidthStyle.max;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
selectionWidthStyle: selectionWidthStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.selectionWidthStyle, selectionWidthStyle);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Passes dragStartBehavior to dragStartBehavior TextField', (WidgetTester tester) async {
|
||||||
|
const DragStartBehavior dragStartBehavior = DragStartBehavior.down;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
dragStartBehavior: dragStartBehavior,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Finder textFieldFinder = find.byType(TextField);
|
||||||
|
expect(textFieldFinder, findsOneWidget);
|
||||||
|
|
||||||
|
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||||
|
expect(textFieldWidget.dragStartBehavior, dragStartBehavior);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('Error color for cursor while validating', (WidgetTester tester) async {
|
testWidgets('Error color for cursor while validating', (WidgetTester tester) async {
|
||||||
const Color errorColor = Color(0xff123456);
|
const Color errorColor = Color(0xff123456);
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user