如何在DraggableScrollableSheet中设计日期,因为年份太深,而且与月份很接近。如何进行时间设计。
代码日期:
void _showDatePickerBottomSheet(BuildContext context) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) {
return GestureDetector(
onTap: () {
Navigator.of(context).pop();
setState(() {});
},
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
color: const Color.fromRGBO(0, 0, 0, 0.001),
child: GestureDetector(
onTap: () {},
child: ScrollConfiguration(
behavior:
ScrollConfiguration.of(context).copyWith(dragDevices: {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
}),
child: DraggableScrollableSheet(
initialChildSize: 0.5,
minChildSize: 0.2,
maxChildSize: 1,
builder: (_, controller) {
return Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25.0),
topRight: Radius.circular(25.0),
),
),
child: SizedBox(
height: 200,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
initialDateTime: DateTime.now(),
onDateTimeChanged: (DateTime newDateTime) {
//_selectedReadingDate = newDateTime;
_readingDate = DateFormat('dd/MM/yyyy')
.format(newDateTime)
.toString();
},
),
),
);
},
),
),
),
),
);
},
);
}
代码时间:
void _showTimePickerBottomSheet(BuildContext context) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) {
return GestureDetector(
onTap: () {
Navigator.of(context).pop();
setState(() {});
},
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
color: const Color.fromRGBO(0, 0, 0, 0.001),
child: GestureDetector(
onTap: () {},
child: ScrollConfiguration(
behavior:
ScrollConfiguration.of(context).copyWith(dragDevices: {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
}),
child: DraggableScrollableSheet(
initialChildSize: 0.5,
minChildSize: 0.2,
maxChildSize: 1,
builder: (_, controller) {
return Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25.0),
topRight: Radius.circular(25.0),
),
),
child: SizedBox(
height: 200,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.time,
initialDateTime: DateTime.now(),
onDateTimeChanged: (DateTime newDateTime) {
_readingTime = DateFormat('hh:mm a')
.format(newDateTime)
.toString();
_readingTimeIn24HourFormat = DateFormat('HH:mm:ss')
.format(newDateTime)
.toString();
},
),
),
);
},
),
),
),
),
);
},
);
}
我设置了initialChildSize,minChildSize,maxChildSize我设置了相同的.但对于日期年太向内弯曲.有没有办法使年不向内弯曲?有没有人可以帮助?
1条答案
按热度按时间sxissh061#