In the Flutter Date Range Picker, you can style the header by using headerStyle property in the onViewChanged callback of the date range picker. In onViewChanged callback, style the date range picker header by using DateRangePickerHeaderStyle properties. void viewChanged(DateRangePickerViewChangedArgs viewChangedDetails) { final DateTime startDate = viewChangedDetails.visibleDateRange.startDate!; final DateTime endDate = viewChangedDetails.visibleDateRange.endDate!; final int count = endDate.difference(startDate).inDays; final DateTime midDate = startDate.add(Duration(days: count ~/ 2)); SchedulerBinding.instance!.addPostFrameCallback((duration) { setState(() { if (midDate.month % 2 == 0) { _headerStyle = DateRangePickerHeaderStyle( textAlign: TextAlign.center, backgroundColor: Colors.lightGreen, textStyle: TextStyle( fontSize: 25, fontStyle: FontStyle.normal, letterSpacing: 5, color: Colors.red, fontWeight: FontWeight.w500)); } else { _headerStyle = DateRangePickerHeaderStyle( textAlign: TextAlign.center, backgroundColor: Colors.purple, textStyle: TextStyle( fontSize: 25, fontStyle: FontStyle.normal, letterSpacing: 5, color: Colors.orange, fontWeight: FontWeight.w500)); } }); }); } Assign _headerStyle to the headerStyle property of the date range picker. child: SfDateRangePicker( headerStyle: _headerStyle, onViewChanged: viewChanged, ),
|
This page will automatically be redirected to the sign-in page in 10 seconds.