gpt4 book ai didi

flutter - Flutter 中的 IOS 日期选择器

转载 作者:行者123 更新时间:2023-12-05 06:08:03 26 4
gpt4 key购买 nike

我只想使用 Cupertino 制作一个日期选择器。像下面的东西

enter image description here

但我所能做的就是...有人能帮忙吗?

Container(
height: MediaQuery.of(context).copyWith().size.height / 3,
child: CupertinoDatePicker(
initialDateTime: DateTime.now(),
onDateTimeChanged: (DateTime newdate) {
print(newdate);
setState(() {
_currentdate = newdate;
});
},
use24hFormat: true,
maximumDate: new DateTime(2050, 12, 30),
minimumYear: 2010,
maximumYear: 2018,
minuteInterval: 1,
mode: CupertinoDatePickerMode.dateAndTime,
),
),

最佳答案

  1. 在库比蒂诺日期选择器的顶部添加一行。
  2. 使用 intl 包格式化所选日期。
           Column(
children: [
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey, width: 0.5))),
padding: EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Due date',
style: TextStyle(
color: Colors.grey,
fontSize: 17),
),
Text(
DateFormat('MMM, dd yyyy').format(_currentdate??DateTime.now(),
style: TextStyle(
color: Colors.blue,
fontSize: 17),
),
],
),
),
Container(
height: MediaQuery.of(context).copyWith().size.height / 3,
child: CupertinoDatePicker(
initialDateTime: DateTime.now(),
onDateTimeChanged: (DateTime newdate) {
print(newdate);
setState(() {
_currentdate = newdate;
});
},
use24hFormat: true,
maximumDate: new DateTime(2050, 12, 30),
minimumYear: 2010,
maximumYear: 2018,
minuteInterval: 1,
mode: CupertinoDatePickerMode.dateAndTime,
),
),
]),

关于flutter - Flutter 中的 IOS 日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65198454/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com