diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 068b8bcb76..df376b5534 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -819,7 +819,7 @@ static NSString* uniqueIdFromDictionary(NSDictionary* dictionary) { if (self) { _nonAutofillInputView = [[FlutterTextInputView alloc] init]; _nonAutofillInputView.secureTextEntry = NO; - _nonAutofillInputView = [[FlutterTextInputView alloc] init]; + _nonAutofillSecureInputView = [[FlutterTextInputView alloc] init]; _nonAutofillSecureInputView.secureTextEntry = YES; _inputViews = [[NSMutableArray alloc] init]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index df6e1a5a2f..a8eb3ce006 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -14,7 +14,43 @@ FLUTTER_ASSERT_ARC @end @implementation FlutterTextInputPluginTest +- (void)testSecureInput { + // Setup test. + id engine = OCMClassMock([FlutterEngine class]); + FlutterTextInputPlugin* textInputPlugin = [[FlutterTextInputPlugin alloc] init]; + textInputPlugin.textInputDelegate = engine; + NSDictionary* config = @{ + @"inputType" : @{@"name" : @"TextInuptType.text"}, + @"keyboardAppearance" : @"Brightness.light", + @"obscureText" : @YES, + @"inputAction" : @"TextInputAction.unspecified", + @"smartDashesType" : @"0", + @"smartQuotesType" : @"0", + @"autocorrect" : @YES + }; + + FlutterMethodCall* setClientCall = + [FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient" + arguments:@[ @123, config ]]; + + [textInputPlugin handleMethodCall:setClientCall + result:^(id _Nullable result){ + }]; + + // Find all input views in the input hider view. + NSArray* inputFields = + [[[textInputPlugin textInputView] superview] subviews]; + + // Find the inactive autofillable input field. + FlutterTextInputView* inputView = inputFields[0]; + + // Verify secureTextEntry is set to the correct value. + XCTAssertTrue(inputView.secureTextEntry); + + // Clean up mocks + [engine stopMocking]; +} - (void)testAutofillInputViews { // Setup test. id engine = OCMClassMock([FlutterEngine class]);