Skip to content

Commit

Permalink
Add support for TextInputType.emailAddress (flutter#3729)
Browse files Browse the repository at this point in the history
Adds support for requesting a platform keyboard optimised for entering
email addresses.
  • Loading branch information
cbracken authored Jun 2, 2017
1 parent 9af413c commit f990f8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ private static int inputTypeFromTextInputType(String inputType, boolean obscureT
return InputType.TYPE_CLASS_NUMBER;
if (inputType.equals("TextInputType.phone"))
return InputType.TYPE_CLASS_PHONE;
return obscureText
? InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
: InputType.TYPE_CLASS_TEXT;

int textType = InputType.TYPE_CLASS_TEXT;
if (inputType.equals("TextInputType.emailAddress"))
textType |= InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
if (obscureText)
textType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
return textType;
}

public InputConnection createInputConnection(FlutterView view, EditorInfo outAttrs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ static UIKeyboardType ToUIKeyboardType(NSString* inputType) {
return UIKeyboardTypeDecimalPad;
if ([inputType isEqualToString:@"TextInputType.phone"])
return UIKeyboardTypePhonePad;
if ([inputType isEqualToString:@"TextInputType.emailAddress"])
return UIKeyboardTypeEmailAddress;
return UIKeyboardTypeDefault;
}

Expand Down

0 comments on commit f990f8b

Please sign in to comment.