【发布时间】:2021-07-27 01:22:36
【问题描述】:
我使用 textformfield 进行验证,使用表单而不是文本我想要的是让用户选择日期。所以这是我的问题如何禁用在文本字段上点击打开键盘以便我可以显示我的 Datepicker?这是我的小部件
String _date = "Please pick Age";
Widget _buildage() {
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(
'Enter Age',
style: kLabelStyle,
),
SizedBox(height: 10.0),
GestureDetector(
onTap: () {
DatePicker.showDatePicker(context,
theme: DatePickerTheme(
containerHeight: 210.0,
),
showTitleActions: true,
minTime: DateTime(2000, 1, 1),
maxTime: DateTime(2022, 12, 31), onConfirm: (date) {
print('confirm $date');
setState(() {
_date = '${date.year} - ${date.month} - ${date.day}';
});
}, currentTime: DateTime.now(), locale: LocaleType.en);
},
child: Container(
decoration: kBoxDecorationStyle,
alignment: Alignment.centerLeft,
height: 60.0,
child: Container(
child: TextFormField(
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.only(top: 14.0),
prefixIcon: Icon(
Icons.date_range_rounded,
color: Colors.white,
size: 28,
),
hintText: " $_date",
hintStyle: kHintTextStyle,
),
),
),
),
),
]);
}
希望任何人都可以帮助我也使用其他一些 Textformfield,但我只想在小部件中禁用它。
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore