Giter Site home page Giter Site logo

syncfusionexamples / visible-dates-date-range-picker-flutter Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 3.0 68 KB

How to get the current view dates in flutter date range picker (SfDateRangePicker)?

Kotlin 9.16% Swift 8.61% Objective-C 0.79% Dart 81.44%

visible-dates-date-range-picker-flutter's Introduction

How to get the current view dates in Flutter date range picker (SfDateRangePicker)?

In flutter date range picker, you can get the current month start and end dates using the onViewChanged callback.

Step 1:

Inside the state, initialize the controller for the date range picker and set the default values for start and end date of the current month.

final DateRangePickerController _controller = DateRangePickerController();
String _startDate = '', _endDate = '';

Step 2:

Place the date picker inside the body of the Scaffold widget and trigger the onViewChanged callback of the date picker.

body: Column(
  children: <Widget>[
    Container( height:50,
        child: Text('StartDate:''$_startDate')),
    Container(height:50
        ,child: Text('EndDate:''$_endDate')),
    Card(
      margin: const EdgeInsets.fromLTRB(40, 100, 50, 40),
      child: SfDateRangePicker(
        controller: _controller,
        view: DateRangePickerView.month,
        onViewChanged: viewChanged,
      ),
    )
  ],
),

Step 3:

Using the onViewChanged callback of the date picker get the start and dates of the current month.

void viewChanged(DateRangePickerViewChangedArgs args) {
 
    _startDate = DateFormat('dd, MMMM yyyy')
        .format(args.visibleDateRange.startDate!)
        .toString();
    _endDate=DateFormat('dd, MMMM yyyy')
        .format(args.visibleDateRange.endDate!)
        .toString();
    SchedulerBinding.instance!.addPostFrameCallback((duration) {
      setState(() {});
    });
}

View document in Syncfusion Flutter Knowledge base

Screenshots

Month view| Year view| Decade view| Century view|

visible-dates-date-range-picker-flutter's People

Contributors

indumathi1195r avatar jayaleshwari avatar muthulakshmi-123 avatar nijamudeen-mohamed avatar sarubala20 avatar sasikumar3595 avatar vinothkumar-ganesan avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.