我有这个时间选择器代码,然后我想从DateTime变量中设置初始时间:
Future<Null> _selectTime(BuildContext context) async {
final TimeOfDay pickedS = await showTimePicker(
context: context,
initialTime: createdAt,
builder: (BuildContext context, Widget child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: false),
child: child,
);});
if (pickedS != null && pickedS != selectedTime )
setState(() {
selectedTime = pickedS;
myTweets[actualTweetIndex].createdAt = dateFormat.format(selectedDate.toLocal()) +' ${selectedTime.hour}:${selectedTime.minute}:00 +0000 '+ selectedDate.year.toString();
});
}