Articles in this section
Category / Section

How to add custom fonts in the Flutter Date Range Picker (SfDateRangePicker)

1 min read

In the Flutter date range picker, you can add the custom fonts for headerStyle, viewHeaderStyle, monthCellStyle, yearCellStyle.

STEP 1: Create a font folder and add the required custom fonts.

fonts

STEP 2: Specify custom fonts in Pubspec.yaml file.

fonts:
  - family: Roboto
    fonts:
      - asset: fonts/Roboto-Italic.ttf
        weight: 700
  - family: SyneTactile
    fonts:
      - asset: fonts/SyneTactile-Regular.ttf
        weight: 700

STEP 3: Apply the custom fonts in headerStyle, viewHeaderStyle, monthCellStyle, yearCellStyle of the calendar.

child: SfDateRangePicker(
  view: DateRangePickerView.month,
  headerStyle: DateRangePickerHeaderStyle(
      textStyle: TextStyle(
          fontFamily: 'SyneTactile', color: Colors.black)),
  monthViewSettings: DateRangePickerMonthViewSettings(
    viewHeaderStyle: DateRangePickerViewHeaderStyle(
        textStyle: TextStyle(
            fontFamily: 'SyneTactile', color: Colors.black)),
  ),
  monthCellStyle: DateRangePickerMonthCellStyle(
      textStyle:
          TextStyle(fontFamily: 'SyneTactile', color: Colors.black),
      todayTextStyle: TextStyle(
          fontFamily: 'SyneTactile', color: Colors.black)),
  yearCellStyle: DateRangePickerYearCellStyle(
    textStyle:
        TextStyle(fontFamily: 'SyneTactile', color: Colors.black),
    disabledDatesTextStyle: const TextStyle(
        fontFamily: 'SyneTactile', color: Colors.black),
    todayTextStyle:
        TextStyle(fontFamily: 'SyneTactile', color: Colors.black),
    leadingDatesTextStyle:
        TextStyle(fontFamily: 'SyneTactile', color: Colors.black),
  ),
),

View sample in GitHub

          Month view

month

           Year view

year

          Decade view

decade

           Century view

century

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied