diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 88d7328e39e..28c73fb23bd 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -154,6 +154,7 @@ class TextFormField extends FormField { bool enableIMEPersonalizedLearning = true, MouseCursor? mouseCursor, EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder, + SpellCheckConfiguration? spellCheckConfiguration, TextMagnifierConfiguration? magnifierConfiguration, }) : assert(initialValue == null || controller == null), assert(obscuringCharacter.length == 1), @@ -235,6 +236,7 @@ class TextFormField extends FormField { enableIMEPersonalizedLearning: enableIMEPersonalizedLearning, mouseCursor: mouseCursor, contextMenuBuilder: contextMenuBuilder, + spellCheckConfiguration: spellCheckConfiguration, magnifierConfiguration: magnifierConfiguration, ), ); diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index 7bde02667dd..fe68311de01 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -1145,6 +1145,36 @@ void main() { skip: kIsWeb, // [intended] we don't supply the cut/copy/paste buttons on the web. ); + testWidgets('spellCheckConfiguration passes through to EditableText', (WidgetTester tester) async { + final SpellCheckConfiguration mySpellCheckConfiguration = SpellCheckConfiguration( + spellCheckService: DefaultSpellCheckService(), + misspelledTextStyle: TextField.materialMisspelledTextStyle, + ); + + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: TextFormField( + spellCheckConfiguration: mySpellCheckConfiguration, + ), + ), + )); + + expect(find.byType(EditableText), findsOneWidget); + + final EditableText editableText = tester.widget(find.byType(EditableText)); + + // Can't do equality comparison on spellCheckConfiguration itself because it + // will have been copied. + expect( + editableText.spellCheckConfiguration?.spellCheckService, + equals(mySpellCheckConfiguration.spellCheckService), + ); + expect( + editableText.spellCheckConfiguration?.misspelledTextStyle, + equals(mySpellCheckConfiguration.misspelledTextStyle), + ); + }); + testWidgets('magnifierConfiguration passes through to EditableText', (WidgetTester tester) async { final TextMagnifierConfiguration myTextMagnifierConfiguration = TextMagnifierConfiguration( magnifierBuilder: (BuildContext context, MagnifierController controller, ValueNotifier notifier) { @@ -1154,7 +1184,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: Scaffold( - body: TextField( + body: TextFormField( magnifierConfiguration: myTextMagnifierConfiguration, ), ),