diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index c47a5566e5839..f02ab85da7ece 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -878,9 +878,11 @@ - (void)configureWithDictionary:(NSDictionary*)configuration { self.keyboardAppearance = UIKeyboardAppearanceDefault; } NSString* autocorrect = configuration[kAutocorrectionType]; - self.autocorrectionType = autocorrect && ![autocorrect boolValue] - ? UITextAutocorrectionTypeNo - : UITextAutocorrectionTypeDefault; + bool autocorrectIsDisabled = autocorrect && ![autocorrect boolValue]; + self.autocorrectionType = + autocorrectIsDisabled ? UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault; + self.spellCheckingType = + autocorrectIsDisabled ? UITextSpellCheckingTypeNo : UITextSpellCheckingTypeDefault; self.autofillId = AutofillIdFromDictionary(configuration); if (autofill == nil) { self.textContentType = @""; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index 701621273cd3f..f18357acf0ffc 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -769,6 +769,23 @@ - (void)testInputActionContinueAction { OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/textinput" message:encodedMethodCall]); } +- (void)testDisablingAutocorrectDisablesSpellChecking { + FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin]; + + // Disable the interactive selection. + NSDictionary* config = self.mutableTemplateCopy; + [inputView configureWithDictionary:config]; + + XCTAssertEqual(inputView.autocorrectionType, UITextAutocorrectionTypeDefault); + XCTAssertEqual(inputView.spellCheckingType, UITextSpellCheckingTypeDefault); + + [config setValue:@(NO) forKey:@"autocorrect"]; + [inputView configureWithDictionary:config]; + + XCTAssertEqual(inputView.autocorrectionType, UITextAutocorrectionTypeNo); + XCTAssertEqual(inputView.spellCheckingType, UITextSpellCheckingTypeNo); +} + #pragma mark - TextEditingDelta tests - (void)testTextEditingDeltasAreGeneratedOnTextInput { FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];