feat: Add keyboardType in CupertinoSearchTextField (#83994)
This commit is contained in:
@@ -108,6 +108,7 @@ class CupertinoSearchTextField extends StatefulWidget {
|
||||
this.decoration,
|
||||
this.backgroundColor,
|
||||
this.borderRadius,
|
||||
this.keyboardType = TextInputType.text,
|
||||
this.padding = const EdgeInsetsDirectional.fromSTEB(3.8, 8, 5, 8),
|
||||
this.itemColor = CupertinoColors.secondaryLabel,
|
||||
this.itemSize = 20.0,
|
||||
@@ -195,6 +196,11 @@ class CupertinoSearchTextField extends StatefulWidget {
|
||||
// https://github.com/flutter/flutter/issues/13914.
|
||||
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.
|
||||
///
|
||||
/// Cannot be null. Defaults to padding that replicates the
|
||||
@@ -440,6 +446,7 @@ class _CupertinoSearchTextFieldState extends State<CupertinoSearchTextField>
|
||||
style: widget.style,
|
||||
prefix: prefix,
|
||||
suffix: suffix,
|
||||
keyboardType: widget.keyboardType,
|
||||
onTap: widget.onTap,
|
||||
enabled: widget.enabled,
|
||||
suffixMode: widget.suffixMode,
|
||||
|
||||
@@ -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(
|
||||
'can control text content via controller',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user