Unverified Commit 5de09188 authored by Hardeep Singh's avatar Hardeep Singh Committed by GitHub

feat: Add keyboardType in CupertinoSearchTextField (#83994)

parent ad2005c4
...@@ -108,6 +108,7 @@ class CupertinoSearchTextField extends StatefulWidget { ...@@ -108,6 +108,7 @@ class CupertinoSearchTextField extends StatefulWidget {
this.decoration, this.decoration,
this.backgroundColor, this.backgroundColor,
this.borderRadius, this.borderRadius,
this.keyboardType = TextInputType.text,
this.padding = const EdgeInsetsDirectional.fromSTEB(3.8, 8, 5, 8), this.padding = const EdgeInsetsDirectional.fromSTEB(3.8, 8, 5, 8),
this.itemColor = CupertinoColors.secondaryLabel, this.itemColor = CupertinoColors.secondaryLabel,
this.itemSize = 20.0, this.itemSize = 20.0,
...@@ -195,6 +196,11 @@ class CupertinoSearchTextField extends StatefulWidget { ...@@ -195,6 +196,11 @@ class CupertinoSearchTextField extends StatefulWidget {
// https://github.com/flutter/flutter/issues/13914. // https://github.com/flutter/flutter/issues/13914.
final BorderRadius? borderRadius; final BorderRadius? borderRadius;
/// The keyboard type for this search field.
///
/// Defaults to TextInputType.text.
final TextInputType? keyboardType;
/// Sets the padding insets for the text and placeholder. /// Sets the padding insets for the text and placeholder.
/// ///
/// Cannot be null. Defaults to padding that replicates the /// Cannot be null. Defaults to padding that replicates the
...@@ -440,6 +446,7 @@ class _CupertinoSearchTextFieldState extends State<CupertinoSearchTextField> ...@@ -440,6 +446,7 @@ class _CupertinoSearchTextFieldState extends State<CupertinoSearchTextField>
style: widget.style, style: widget.style,
prefix: prefix, prefix: prefix,
suffix: suffix, suffix: suffix,
keyboardType: widget.keyboardType,
onTap: widget.onTap, onTap: widget.onTap,
enabled: widget.enabled, enabled: widget.enabled,
suffixMode: widget.suffixMode, suffixMode: widget.suffixMode,
......
...@@ -112,6 +112,22 @@ void main() { ...@@ -112,6 +112,22 @@ void main() {
}, },
); );
testWidgets('can change keyboard type', (WidgetTester tester) async {
await tester.pumpWidget(
const CupertinoApp(
home: Center(
child: CupertinoSearchTextField(
keyboardType: TextInputType.number,
),
),
),
);
await tester.tap(find.byType(CupertinoSearchTextField));
await tester.showKeyboard(find.byType(CupertinoSearchTextField));
expect((tester.testTextInput.setClientArgs!['inputType'] as Map<String, dynamic>)['name'], equals('TextInputType.number'));
},
);
testWidgets( testWidgets(
'can control text content via controller', 'can control text content via controller',
(WidgetTester tester) async { (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment