Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a485d3f

Browse files
committed
[TextInput] Add TextInputType.webSearch (#15762)
1 parent f564010 commit a485d3f

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,8 @@ public enum TextInputType {
717717
EMAIL_ADDRESS("TextInputType.emailAddress"),
718718
URL("TextInputType.url"),
719719
VISIBLE_PASSWORD("TextInputType.visiblePassword"),
720-
NONE("TextInputType.none");
720+
NONE("TextInputType.none"),
721+
WEB_SEARCH("TextInputType.webSearch");
721722

722723
static TextInputType fromValue(@NonNull String encodedName) throws NoSuchFieldException {
723724
for (TextInputType textInputType : TextInputType.values()) {

shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ private static int inputTypeFromTextInputType(
252252
textType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
253253
} else if (type.type == TextInputChannel.TextInputType.EMAIL_ADDRESS) {
254254
textType |= InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
255-
} else if (type.type == TextInputChannel.TextInputType.URL) {
255+
} else if (type.type == TextInputChannel.TextInputType.URL
256+
|| type.type == TextInputChannel.TextInputType.WEB_SEARCH) {
256257
textType |= InputType.TYPE_TEXT_VARIATION_URI;
257258
} else if (type.type == TextInputChannel.TextInputType.VISIBLE_PASSWORD) {
258259
textType |= InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ static UIKeyboardType ToUIKeyboardType(NSDictionary* type) {
140140
if ([inputType isEqualToString:@"TextInputType.visiblePassword"]) {
141141
return UIKeyboardTypeASCIICapable;
142142
}
143+
if ([inputType isEqualToString:@"TextInputType.webSearch"]) {
144+
return UIKeyboardTypeWebSearch;
145+
}
143146
return UIKeyboardTypeDefault;
144147
}
145148

shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,20 @@ - (void)testKeyboardType {
307307
XCTAssertEqual(inputView.keyboardType, UIKeyboardTypeURL);
308308
}
309309

310+
- (void)testKeyboardTypeWebSearch {
311+
NSDictionary* config = self.mutableTemplateCopy;
312+
[config setValue:@{@"name" : @"TextInputType.webSearch"} forKey:@"inputType"];
313+
[self setClientId:123 configuration:config];
314+
315+
// Find all the FlutterTextInputViews we created.
316+
NSArray<FlutterTextInputView*>* inputFields = self.installedInputViews;
317+
318+
FlutterTextInputView* inputView = inputFields[0];
319+
320+
// Verify keyboardType is set to the value specified in config.
321+
XCTAssertEqual(inputView.keyboardType, UIKeyboardTypeWebSearch);
322+
}
323+
310324
- (void)testVisiblePasswordUseAlphanumeric {
311325
NSDictionary* config = self.mutableTemplateCopy;
312326
[config setValue:@{@"name" : @"TextInputType.visiblePassword"} forKey:@"inputType"];

0 commit comments

Comments
 (0)