Skip to content

Commit dd3dc5e

Browse files
authored
TextFormField.spellCheckConfiguration (#123295)
TextFormField.spellCheckConfiguration
1 parent 142dd60 commit dd3dc5e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/flutter/lib/src/material/text_form_field.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class TextFormField extends FormField<String> {
154154
bool enableIMEPersonalizedLearning = true,
155155
MouseCursor? mouseCursor,
156156
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
157+
SpellCheckConfiguration? spellCheckConfiguration,
157158
TextMagnifierConfiguration? magnifierConfiguration,
158159
}) : assert(initialValue == null || controller == null),
159160
assert(obscuringCharacter.length == 1),
@@ -235,6 +236,7 @@ class TextFormField extends FormField<String> {
235236
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
236237
mouseCursor: mouseCursor,
237238
contextMenuBuilder: contextMenuBuilder,
239+
spellCheckConfiguration: spellCheckConfiguration,
238240
magnifierConfiguration: magnifierConfiguration,
239241
),
240242
);

packages/flutter/test/material/text_form_field_test.dart

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,36 @@ void main() {
11451145
skip: kIsWeb, // [intended] we don't supply the cut/copy/paste buttons on the web.
11461146
);
11471147

1148+
testWidgets('spellCheckConfiguration passes through to EditableText', (WidgetTester tester) async {
1149+
final SpellCheckConfiguration mySpellCheckConfiguration = SpellCheckConfiguration(
1150+
spellCheckService: DefaultSpellCheckService(),
1151+
misspelledTextStyle: TextField.materialMisspelledTextStyle,
1152+
);
1153+
1154+
await tester.pumpWidget(MaterialApp(
1155+
home: Scaffold(
1156+
body: TextFormField(
1157+
spellCheckConfiguration: mySpellCheckConfiguration,
1158+
),
1159+
),
1160+
));
1161+
1162+
expect(find.byType(EditableText), findsOneWidget);
1163+
1164+
final EditableText editableText = tester.widget(find.byType(EditableText));
1165+
1166+
// Can't do equality comparison on spellCheckConfiguration itself because it
1167+
// will have been copied.
1168+
expect(
1169+
editableText.spellCheckConfiguration?.spellCheckService,
1170+
equals(mySpellCheckConfiguration.spellCheckService),
1171+
);
1172+
expect(
1173+
editableText.spellCheckConfiguration?.misspelledTextStyle,
1174+
equals(mySpellCheckConfiguration.misspelledTextStyle),
1175+
);
1176+
});
1177+
11481178
testWidgets('magnifierConfiguration passes through to EditableText', (WidgetTester tester) async {
11491179
final TextMagnifierConfiguration myTextMagnifierConfiguration = TextMagnifierConfiguration(
11501180
magnifierBuilder: (BuildContext context, MagnifierController controller, ValueNotifier<MagnifierInfo> notifier) {
@@ -1154,7 +1184,7 @@ void main() {
11541184

11551185
await tester.pumpWidget(MaterialApp(
11561186
home: Scaffold(
1157-
body: TextField(
1187+
body: TextFormField(
11581188
magnifierConfiguration: myTextMagnifierConfiguration,
11591189
),
11601190
),

0 commit comments

Comments
 (0)