From 96923da9172cc0bb8c9d98e651044474c128eebc Mon Sep 17 00:00:00 2001 From: Sasikumar Arumugam Date: Wed, 7 Apr 2021 12:23:26 +0530 Subject: [PATCH] FLUT-4313-Sample updated with null safety. --- lib/main.dart | 39 ++++++------ pubspec.lock | 161 ++++++++++++-------------------------------------- pubspec.yaml | 10 ++-- 3 files changed, 61 insertions(+), 149 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index ba9e847..96891e3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,14 +23,8 @@ class MultiplePickerSample extends StatefulWidget { } class _MultiplePickerSampleState extends State { - DateRangePickerController _controller; - String _headerString; - - @override - void initState() { - _controller = DateRangePickerController(); - super.initState(); - } + final DateRangePickerController _controller = DateRangePickerController(); + String _headerString = ''; @override Widget build(BuildContext context) { @@ -57,7 +51,7 @@ class _MultiplePickerSampleState extends State { highlightColor: Colors.lightGreen, onPressed: () { setState(() { - _controller.backward(); + _controller.backward!(); }); }, )), @@ -82,7 +76,7 @@ class _MultiplePickerSampleState extends State { highlightColor: Colors.lightGreen, onPressed: () { setState(() { - _controller.forward(); + _controller.forward!(); }); }, )), @@ -100,10 +94,9 @@ class _MultiplePickerSampleState extends State { enableMultiView: true, onViewChanged: viewChanged, monthViewSettings: DateRangePickerMonthViewSettings( - showTrailingAndLeadingDates: true, viewHeaderStyle: DateRangePickerViewHeaderStyle( - backgroundColor: Color(0xFFfcc169), - )), + backgroundColor: Color(0xFFfcc169), + )), ), ), ) @@ -112,16 +105,18 @@ class _MultiplePickerSampleState extends State { } void viewChanged(DateRangePickerViewChangedArgs args) { - final int count = (args.visibleDateRange.endDate - .difference(args.visibleDateRange.startDate) - .inDays); - /// For updating proper custom header string if showLeadingAndTrailingDates value as true/false. + final DateTime startDate = args.visibleDateRange.startDate!; + final DateTime endDate = args.visibleDateRange.endDate!; + final int count = endDate.difference(startDate).inDays; + _headerString = DateFormat('MMMM yyyy') - .format(args.visibleDateRange.startDate.add(Duration(days: (count * 0.25).toInt()))) - .toString() + ' - ' +DateFormat('MMMM yyyy') - .format(args.visibleDateRange.startDate.add(Duration(days: (count * 0.75).toInt()))) - .toString(); - SchedulerBinding.instance.addPostFrameCallback((duration) { + .format(startDate.add(Duration(days: (count * 0.25).toInt()))) + .toString() + + ' - ' + + DateFormat('MMMM yyyy') + .format(startDate.add(Duration(days: (count * 0.75).toInt()))) + .toString(); + SchedulerBinding.instance!.addPostFrameCallback((duration) { setState(() {}); }); } diff --git a/pubspec.lock b/pubspec.lock index a0565cc..424bd75 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,69 +1,62 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" - charcode: + version: "2.1.0" + characters: dependency: transitive description: - name: charcode + name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" - collection: + version: "1.1.0" + charcode: dependency: transitive description: - name: collection + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: + version: "1.2.0" + clock: dependency: transitive description: - name: convert + name: clock url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.1.0" + collection: dependency: transitive description: - name: crypto + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.0.2" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -74,67 +67,34 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" intl: - dependency: "direct dev" + dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -146,112 +106,69 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" syncfusion_flutter_core: dependency: transitive description: name: syncfusion_flutter_core url: "https://pub.dartlang.org" source: hosted - version: "18.2.44" + version: "19.1.55" syncfusion_flutter_datepicker: - dependency: "direct dev" + dependency: "direct main" description: name: syncfusion_flutter_datepicker url: "https://pub.dartlang.org" source: hosted - version: "18.2.44-beta" + version: "19.1.55-beta" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" - url_launcher: - dependency: transitive - description: - name: url_launcher - url: "https://pub.dartlang.org" - source: hosted - version: "5.4.2" - url_launcher_macos: - dependency: transitive - description: - name: url_launcher_macos - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.1+4" - url_launcher_platform_interface: - dependency: transitive - description: - name: url_launcher_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.6" - url_launcher_web: - dependency: transitive - description: - name: url_launcher_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.1+1" - utf: - dependency: transitive - description: - name: utf - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.0+5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" + version: "2.1.0" sdks: - dart: ">=2.6.0 <3.0.0" - flutter: ">=1.12.8 <2.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index c21c6f7..73b66a9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,22 +14,22 @@ description: A new Flutter application. version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter + + syncfusion_flutter_datepicker: ^19.1.55-beta + intl: ^0.17.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: sdk: flutter - syncfusion_flutter_datepicker: 18.2.44-beta - intl: ">=0.15.0 <0.17.0" - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec