我有以下日历和代码。我怎样才能让月份只有 3 个字母,例如 Nov 2021 而不是 October 2021。
Container(
height: MediaQuery.of(context).size.height*0.3,
// width: MediaQuery.of(context).size.width*0.3,
color: Colors.white,
child: TableCalendar(
headerStyle: HeaderStyle(
titleTextStyle: TextStyle(fontSize: 12)
),
shouldFillViewport: true,
rowHeight:MediaQuery.of(context).size.height*0.02,
firstDay: DateTime.utc(2010, 10, 16),
lastDay: DateTime.utc(2030, 3, 14),
focusedDay: DateTime.now(),
onDaySelected: (selectedDay, focusedDay) {
if (!isSameDay(_selectedDay, selectedDay)) {
// Call `setState()` when updating the selected day
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
}
}
),
),
Run Code Online (Sandbox Code Playgroud)
作为新的 table_calender 3.0.8,您可以设置禁用两周/格式按钮
availableCalendarFormats: const {
CalendarFormat.month : 'Month'
}
Run Code Online (Sandbox Code Playgroud)
并且为了使标题居中,您还需要设置
headerStyle: HeaderStyle(
titleCentered: true
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4876 次 |
| 最近记录: |