@@ -11,7 +11,7 @@ import 'package:flutter/cupertino.dart'
1111 OverlayVisibilityMode,
1212 CupertinoIcons;
1313import 'package:flutter/material.dart' show MaterialStateProperty, SearchBar;
14- import 'package:flutter/services.dart' show TextCapitalization;
14+ import 'package:flutter/services.dart' show TextCapitalization, TextInputAction ;
1515import 'package:flutter/widgets.dart' ;
1616
1717import 'platform.dart' ;
@@ -24,12 +24,16 @@ abstract class _BaseData {
2424 this .focusNode,
2525 this .onTap,
2626 this .onChanged,
27+ this .keyboardType,
28+ this .autofocus,
2729 });
2830 final Key ? widgetKey;
2931 final FocusNode ? focusNode;
3032 final TextEditingController ? controller;
3133 final void Function ()? onTap;
3234 final ValueChanged <String >? onChanged;
35+ final TextInputType ? keyboardType;
36+ final bool ? autofocus;
3337}
3438
3539class MaterialSearchBarData extends _BaseData {
@@ -40,6 +44,9 @@ class MaterialSearchBarData extends _BaseData {
4044 super .focusNode,
4145 super .onTap,
4246 super .onChanged,
47+ super .autofocus,
48+ super .keyboardType,
49+
4350 //Material
4451 this .leading,
4552 this .trailing,
@@ -57,6 +64,7 @@ class MaterialSearchBarData extends _BaseData {
5764 this .hintText,
5865 this .onSubmitted,
5966 this .textCapitalization,
67+ this .textInputAction,
6068 });
6169
6270 // final String? hintText;
@@ -76,6 +84,7 @@ class MaterialSearchBarData extends _BaseData {
7684 final String ? hintText;
7785 final ValueChanged <String >? onSubmitted;
7886 final TextCapitalization ? textCapitalization;
87+ final TextInputAction ? textInputAction;
7988}
8089
8190class CupertinoSearchBarData extends _BaseData {
@@ -86,12 +95,13 @@ class CupertinoSearchBarData extends _BaseData {
8695 super .focusNode,
8796 super .onTap,
8897 super .onChanged,
98+ super .autofocus,
99+ super .keyboardType,
89100
90101 //Cupertino
91102 this .onSubmitted,
92103 this .decoration,
93104 this .borderRadius,
94- this .keyboardType,
95105 this .itemColor = CupertinoColors .secondaryLabel,
96106 this .itemSize = 20.0 ,
97107 this .prefixInsets = const EdgeInsetsDirectional .fromSTEB (6 , 0 , 0 , 3 ),
@@ -103,9 +113,8 @@ class CupertinoSearchBarData extends _BaseData {
103113 this .restorationId,
104114 this .smartQuotesType,
105115 this .smartDashesType,
106- this .enableIMEPersonalizedLearning = true ,
107- this .autofocus = false ,
108- this .autocorrect = true ,
116+ this .enableIMEPersonalizedLearning,
117+ this .autocorrect,
109118 this .enabled,
110119 this .padding,
111120 this .backgroundColor,
@@ -127,7 +136,6 @@ class CupertinoSearchBarData extends _BaseData {
127136 final ValueChanged <String >? onSubmitted;
128137 final BoxDecoration ? decoration;
129138 final BorderRadius ? borderRadius;
130- final TextInputType ? keyboardType;
131139 final Color itemColor;
132140 final double itemSize;
133141 final EdgeInsetsGeometry prefixInsets;
@@ -140,9 +148,8 @@ class CupertinoSearchBarData extends _BaseData {
140148
141149 final SmartQuotesType ? smartQuotesType;
142150 final SmartDashesType ? smartDashesType;
143- final bool enableIMEPersonalizedLearning;
144- final bool autofocus;
145- final bool autocorrect;
151+ final bool ? enableIMEPersonalizedLearning;
152+ final bool ? autocorrect;
146153 final bool ? enabled;
147154 final EdgeInsetsGeometry ? padding;
148155 final Color ? backgroundColor;
@@ -161,6 +168,8 @@ class PlatformSearchBar
161168 final void Function ()? onTap;
162169 final ValueChanged <String >? onChanged;
163170 final Color ? backgroundColor;
171+ final TextInputType ? keyboardType;
172+ final bool ? autoFocus;
164173
165174 //Mixed
166175 final String ? hintText;
@@ -180,6 +189,8 @@ class PlatformSearchBar
180189 this .onTap,
181190 this .onChanged,
182191 this .backgroundColor,
192+ this .keyboardType,
193+ this .autoFocus,
183194 //Mixed
184195 this .hintText,
185196 this .hintStyle,
@@ -216,6 +227,8 @@ class PlatformSearchBar
216227 (textStyle != null
217228 ? MaterialStateProperty .all <TextStyle >(textStyle)
218229 : null ),
230+ autoFocus: data? .autofocus ?? autoFocus ?? false ,
231+ keyboardType: data? .keyboardType ?? keyboardType,
219232
220233 //Material only
221234 leading: data? .leading,
@@ -230,6 +243,8 @@ class PlatformSearchBar
230243 padding: data? .padding,
231244 onSubmitted: data? .onSubmitted,
232245 textCapitalization: data? .textCapitalization,
246+
247+ textInputAction: data? .textInputAction,
233248 );
234249 }
235250
@@ -249,12 +264,13 @@ class PlatformSearchBar
249264 placeholder: data? .placeholder ?? hintText,
250265 placeholderStyle: data? .placeholderStyle ?? hintStyle,
251266 style: data? .style ?? textStyle,
267+ autofocus: data? .autofocus ?? autoFocus ?? false ,
268+ keyboardType: data? .keyboardType ?? keyboardType ?? TextInputType .text,
252269
253270 //Cupertino only
254271 onSubmitted: data? .onSubmitted,
255272 decoration: data? .decoration,
256273 borderRadius: data? .borderRadius,
257- keyboardType: data? .keyboardType,
258274 itemColor: data? .itemColor ?? CupertinoColors .secondaryLabel,
259275 itemSize: data? .itemSize ?? 20.0 ,
260276 prefixInsets: data? .prefixInsets ??
@@ -271,7 +287,6 @@ class PlatformSearchBar
271287 smartDashesType: data? .smartDashesType,
272288 enableIMEPersonalizedLearning:
273289 data? .enableIMEPersonalizedLearning ?? true ,
274- autofocus: data? .autofocus ?? false ,
275290 autocorrect: data? .autocorrect ?? true ,
276291 enabled: data? .enabled,
277292 );
0 commit comments