From 7a3bb0f2bbbc7dc0068c96830632c560b7968d03 Mon Sep 17 00:00:00 2001 From: Indumathi1195R <54974849+Indumathi1195R@users.noreply.github.com> Date: Tue, 5 May 2020 12:17:00 +0530 Subject: [PATCH 1/3] Update README.md Tags and H1 title included. --- README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 756a550..ca5eedd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,57 @@ -# switching-views-date-range-picker-flutter -How to switch between the calendar views in Flutter date range picker? +# How to switch between the date range picker views in Flutter date range picker (SfDateRangePicker)? + + +In the flutter date range picker, you can navigate between the picker views. Switching between picker views has been achieved using the `view` property of DateRangePickerController and tapping the header of the picker views. + +## Step 1: +In initState(), initialize the controller for date range picker. + +```xml +DateRangePickerController _controller; + +@override +void initState() { + // TODO: implement initState + _controller = DateRangePickerController(); + super.initState(); +} +``` + + +## Step 2: +Navigate between the picker views using the PopupMenuButton widget as follows. Also navigating between the picker views can be achieved by tapping the header of the picker views. + +```xml +leading: PopupMenuButton( + icon: Icon(Icons.calendar_today), + itemBuilder: (BuildContext context) => views.map((String choice) { + return PopupMenuItem( + value: choice, + child: Text(choice), + ); + }).toList(), + onSelected: (String value) { + if (value == 'Month') { + _controller.view = DateRangePickerView.month; + } else if (value == 'Year') { + _controller.view = DateRangePickerView.year; + } else if (value == 'Decade') { + _controller.view = DateRangePickerView.decade; + } else if (value == 'Century') { + _controller.view = DateRangePickerView.century; + } + }, +), +``` +Step 3: +Place the calendar inside the body of the Scaffold widget. + +```xml +body: Card( + margin: const EdgeInsets.fromLTRB(50, 150, 50, 150), + child: SfDateRangePicker( + controller: _controller, + view: DateRangePickerView.month, + ), +) +``` From 128c8889b691941bb24d9ab199bdf327b436ceb9 Mon Sep 17 00:00:00 2001 From: Indumathi1195R <54974849+Indumathi1195R@users.noreply.github.com> Date: Tue, 5 May 2020 12:18:26 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca5eedd..b973d8e 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ leading: PopupMenuButton( }, ), ``` -Step 3: +## Step 3: Place the calendar inside the body of the Scaffold widget. ```xml From d9706e2d5c6ee78dcd1bfeac35675c06bdff30b0 Mon Sep 17 00:00:00 2001 From: Indumathi1195R <54974849+Indumathi1195R@users.noreply.github.com> Date: Tue, 5 May 2020 12:21:09 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b973d8e..6609be7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # How to switch between the date range picker views in Flutter date range picker (SfDateRangePicker)? - In the flutter date range picker, you can navigate between the picker views. Switching between picker views has been achieved using the `view` property of DateRangePickerController and tapping the header of the picker views. ## Step 1: