嘿,我要怎样关闭键盘?我希望在点击区域外时可以关闭键盘。
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
child: TextFormField(
keyboardType: TextInputType.number,
maxLength: 10,
controller: widget._phoneController,
onTap: () => FocusScope.of(context).unfocus(),
inputFormatters: [
//input type
FilteringTextInputFormatter.allow(
RegExp(r'[0-9]'),
),
],
//how the text box is decorated
decoration: buildInputDecoration(
Icons.phone, 'Enter your 10 digit phone number'),
),
);
}