Articles in this section
Category / Section

How to display the week number with customization in Flutter date range picker (SfDateRangePicker)

4 mins read

In the Flutter Date Range Picker, show the week number of the month by using the showWeekNumber property of the DateRangePickerMonthViewSettings.

By using the properties of DateRangePickerWeekNumberStyle, customize the week number styles.

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
 
void main() => runApp(const WeekNumber());
 
class WeekNumber extends StatefulWidget {
  const WeekNumber({Key? key}) : super(key: key);
 
  @override
  State<StatefulWidget> createState() => WeekNumberCustomization();
}
 
class WeekNumberCustomization extends State<WeekNumber> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
          body: Card(
        margin: const EdgeInsets.fromLTRB(50, 150, 50, 150),
        child: SafeArea(
          child: SfDateRangePicker(
            monthViewSettings: const DateRangePickerMonthViewSettings(
                showWeekNumber: true,
                weekNumberStyle: DateRangePickerWeekNumberStyle(
                    textStyle: TextStyle(
                      color: Colors.amber,
                    ),
                    backgroundColor: Color(0xFFDF5E5E))),
          ),
        ),
      )),
    );;
  }
}

View sample in GitHub

Flutter DateRangePicker week customization

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