From 9877ce13cfe172e2405cc2b3269a9d909c11d99d Mon Sep 17 00:00:00 2001 From: Bruno D'Luka Date: Thu, 1 Dec 2022 17:37:31 -0300 Subject: [PATCH] Ensure the provided `startYear` and `endYear` in `DateTime` are used properly --- CHANGELOG.md | 1 + example/pubspec.lock | 2 +- lib/src/controls/form/pickers/date_picker.dart | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51d5db6b8..3bbdf9f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Ensure the TabView scroll controller has clients before using it ([#615](https://github.com/bdlukaa/fluent_ui/issues/615)) - TabView now waits a time to resize after closed ([#617](https://github.com/bdlukaa/fluent_ui/issues/617)) - `ToggleButton` border width is uniform ([#610](https://github.com/bdlukaa/fluent_ui/issues/610)) +- Ensure the provided `startYear` and `endYear` in `DateTime` are used properly ([#627](https://github.com/bdlukaa/fluent_ui/issues/627)) ## 4.0.3+1 diff --git a/example/pubspec.lock b/example/pubspec.lock index bc48fb511..9f828e6bb 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -91,7 +91,7 @@ packages: path: ".." relative: true source: path - version: "4.2.0" + version: "4.1.0" flutter: dependency: "direct main" description: flutter diff --git a/lib/src/controls/form/pickers/date_picker.dart b/lib/src/controls/form/pickers/date_picker.dart index b7fa0a7a2..746b5dbd1 100644 --- a/lib/src/controls/form/pickers/date_picker.dart +++ b/lib/src/controls/form/pickers/date_picker.dart @@ -132,6 +132,7 @@ class DatePicker extends StatefulWidget { /// If null, the order is based on the current locale. /// /// See also: + /// /// * [getDateOrderFromLocale], which returns the order of the fields based /// on the current locale final List? fieldOrder; @@ -158,7 +159,10 @@ class DatePicker extends StatefulWidget { ..add(ObjectFlagProperty.has('focusNode', focusNode)) ..add( FlagProperty('autofocus', value: autofocus, ifFalse: 'manual focus')) - ..add(DoubleProperty('popupHeight', popupHeight)); + ..add(DoubleProperty('popupHeight', popupHeight, + defaultValue: kPickerPopupHeight)) + ..add(DiagnosticsProperty('locale', locale)) + ..add(IterableProperty('fieldOrder', fieldOrder)); } } @@ -170,8 +174,8 @@ class _DatePickerState extends State { FixedExtentScrollController? _yearController; int get startYear => - ((widget.startYear ?? DateTime.now().year) - 100).toInt(); - int get endYear => ((widget.endYear ?? DateTime.now().year) + 25).toInt(); + (widget.startYear ?? (DateTime.now().year - 100)).toInt(); + int get endYear => (widget.endYear ?? (DateTime.now().year + 25)).toInt(); int get currentYear { return List.generate(endYear - startYear, (index) {