diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index ad39e710eeb50..0f38f841cc1c4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -45,6 +45,13 @@ static UITextAutocapitalizationType ToUITextAutoCapitalizationType(NSDictionary* return UITextAutocapitalizationTypeNone; } +@available iOS (11.0,*) +static UITextContentType ToUITextContentType(NSDictionary* type) { + NSString* contentType = type[@"textType"]; + if ([contentType isEqualToString:@"TextContent.username"]) + return UITextContentTypeUsername; +} + static UIReturnKeyType ToUIReturnKeyType(NSString* inputType) { // Where did the term "unspecified" come from? iOS has a "default" and Android // has "unspecified." These 2 terms seem to mean the same thing but we need @@ -149,6 +156,13 @@ @interface FlutterTextInputView : UIView @property(nonatomic, strong) UITextRange* markedTextRange; @property(nonatomic, copy) NSDictionary* markedTextStyle; @property(nonatomic, assign) id inputDelegate; +/** + This file is to make ios 11 or higher device using autofill + + Reference to github.com/flutter/flutter/issues/33040 + **/ +@property(nonatomic) UITextContentType textContentType API_AVAILABLE(ios(11.0)); + // UITextInputTraits @property(nonatomic) UITextAutocapitalizationType autocapitalizationType; @@ -191,6 +205,8 @@ - (instancetype)init { _enablesReturnKeyAutomatically = NO; _keyboardAppearance = UIKeyboardAppearanceDefault; _keyboardType = UIKeyboardTypeDefault; + if(@available iOS (11.0,*)) + _keyboardContentType = UITextContentType; _returnKeyType = UIReturnKeyDone; _secureTextEntry = NO; } @@ -754,6 +770,8 @@ - (void)hideTextInput { - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configuration { NSDictionary* inputType = configuration[@"inputType"]; + if(@available iOS (11.0,*)) + NSDictionary* contentType = configuration[@"contentType"]; NSString* keyboardAppearance = configuration[@"keyboardAppearance"]; if ([configuration[@"obscureText"] boolValue]) { _activeView = _secureView; @@ -762,6 +780,8 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur } _activeView.keyboardType = ToUIKeyboardType(inputType); + if(@available iOS (11.0,*)) + _activeView.textContentType = ToUITextContentType(contentType); _activeView.returnKeyType = ToUIReturnKeyType(configuration[@"inputAction"]); _activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration); if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) {