From 0d10984a4772a5bff23813ee8393a4581250bd92 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 2 Jun 2017 15:04:35 -0700 Subject: [PATCH] Add support for TextInputType.emailAddress (flutter/engine#3729) Adds support for requesting a platform keyboard optimised for entering email addresses. --- .../io/flutter/plugin/editing/TextInputPlugin.java | 10 +++++++--- .../ios/framework/Source/FlutterTextInputPlugin.mm | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index 485ae9b2dc..9cbd823bf9 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -80,9 +80,13 @@ public class TextInputPlugin implements MethodCallHandler { 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) 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 4199bafa6d..f80cf49e70 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 @@ -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; }