We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to apply theming in the Flutter Date Range Picker (SfDateRangePicker)

Platform: Flutter |
Control: SfDateRangePicker |
Published Date: August 18, 2020 |
Last Revised Date: May 6, 2021

In Flutter date range picker, we can change theme of the date range picker using the SfDateRangePickerTheme widget.

Step 1:

Use ` SfDateRangePickerTheme ` widget inside the body of the Scaffold. Then add the date range picker as a child of `SfDateRangePickerTheme`.

body: SfDateRangePickerTheme(
  data: SfDateRangePickerThemeData(
    brightness: Brightness.dark,
    backgroundColor: Colors.black,
  ),
  child: Card( margin: const EdgeInsets.fromLTRB(40, 150, 40, 150),
      child: SfDateRangePicker()),
),

 

Step 2:

Please find the entire code snippet for date range picker dark theme.

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
import 'package:syncfusion_flutter_core/theme.dart';
 
void main() => runApp(PickerTheme());
 
class PickerTheme extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: ThemeInPicker(),
    );
  }
}
 
class ThemeInPicker extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => PickerThemeState();
}
 
class PickerThemeState extends State<ThemeInPicker> {
  @override
  Widget build(BuildContext context) {
    return (Scaffold(
      body: SfDateRangePickerTheme(
        data: SfDateRangePickerThemeData(
          brightness: Brightness.dark,
          backgroundColor: Colors.black,
        ),
        child: Card( margin: const EdgeInsets.fromLTRB(40, 150, 40, 150),
            child: SfDateRangePicker()),
      ),
    ));
  }
}

 

View sample in GitHub

Screenshot

 

pickertheme

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile