我只想从tablecalender中获得选定的日期,但它给了我这个输出
2021-08-18 12:00:00.000Z
这里是表日历代码
final dateFormat = DateFormat('yyyy-MMMM-dd');
DateTime _chosenDate = DateTime.now();
child: TableCalendar(
calendarController: _controller,
initialSelectedDay: _chosenDate,
initialCalendarFormat: CalendarFormat.month,
calendarStyle: CalendarStyle(
canEventMarkersOverflow: true,
markersColor: Colors.white,
weekdayStyle: TextStyle(color: Colors.blue[900]),
todayColor: Colors.white54,
todayStyle: TextStyle(color: Colors.blue[900], fontSize: 15, fontWeight: FontWeight.bold),
selectedColor: Colors.blue[900],
outsideWeekendStyle: TextStyle(color: Colors.blue[900]),
outsideStyle: TextStyle(color: Colors.blue[900]),
weekendStyle: TextStyle(color: Colors.blue[900]),
renderDaysOfWeek: false,),
onCalendarCreated: (date,event,_){
},
onDaySelected: (date, event,_) {
setState(() {
_chosenDate = date;
print("_chosenDate");
print(_chosenDate);
});
},
));
}
我试图使用分割方法,但它是不可访问的
请帮助如何使用tablecalender获取日期(2021-08-18
)
将_chosenDate
替换为"${_chosenDate.toString().split(" ").first}"