diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c67400..e444323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 3.2.0 +- Added call back for whenever the user navigates to a different month + ## 3.1.0 - Add compatibility with flutter 3.10 diff --git a/example/pubspec.lock b/example/pubspec.lock index c111d9c..f2fcc37 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "3.1.1" + version: "3.2.0" flutter_lints: dependency: "direct dev" description: diff --git a/lib/src/widgets/date_time_picker/date_time_picker.dart b/lib/src/widgets/date_time_picker/date_time_picker.dart index 675f46e..31a65cd 100644 --- a/lib/src/widgets/date_time_picker/date_time_picker.dart +++ b/lib/src/widgets/date_time_picker/date_time_picker.dart @@ -59,27 +59,32 @@ class DateTimePicker extends StatefulWidget { final Widget Function(void Function()? onPressed)? onPreviousPageButtonBuilder; - const DateTimePicker( - {super.key, - this.child, - required this.theme, - this.weekdayTextStyle = const TextStyle(), - this.onTapDay, - this.highlightToday = true, - this.alwaysUse24HourFormat = true, - this.pickTime = false, - this.initialDate, - this.markedDates, - this.disabledDates, - this.disabledTimes, - required this.size, - this.buttonBuilder, - this.closeOnSelectDate = false, - this.showWeekDays = true, - this.dateTimeConstraint = const DateTimeConstraint(), - this.onNextPageButtonBuilder, - this.onPreviousPageButtonBuilder}); + //final DateTime MonthChangeCallback = void Function(DateTime newMonth); + final void Function(DateTime newMonth)? onMonthChanged; + const DateTimePicker({ + super.key, + this.child, + required this.theme, + this.weekdayTextStyle = const TextStyle(), + this.onTapDay, + this.highlightToday = true, + this.alwaysUse24HourFormat = true, + this.pickTime = false, + this.initialDate, + this.markedDates, + this.disabledDates, + this.disabledTimes, + required this.size, + this.buttonBuilder, + this.closeOnSelectDate = false, + this.showWeekDays = true, + this.dateTimeConstraint = const DateTimeConstraint(), + this.onNextPageButtonBuilder, + this.onPreviousPageButtonBuilder, + this.onMonthChanged, + }); + //final MonthChangeCallback? onMonthChanged; @override State createState() => _DateTimePickerState(); } @@ -103,7 +108,6 @@ class _DateTimePickerState extends State { browsingDate: widget.initialDate ?? DateTime.now(), selectedDate: widget.initialDate ?? DateTime.now(), ); - @override Widget build(BuildContext context) { return Container( @@ -164,6 +168,7 @@ class _DateTimePickerState extends State { _dateTimePickerController.browsingDate.month + 1, _dateTimePickerController.browsingDate.day, ); + widget.onMonthChanged?.call(_dateTimePickerController.browsingDate); }); } @@ -175,6 +180,7 @@ class _DateTimePickerState extends State { _dateTimePickerController.browsingDate.month - 1, _dateTimePickerController.browsingDate.day, ); + widget.onMonthChanged?.call(_dateTimePickerController.browsingDate); }); } } diff --git a/pubspec.yaml b/pubspec.yaml index c670742..1fb0677 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_date_time_picker description: A Flutter package for date and time picker. -version: 3.1.1 +version: 3.2.0 homepage: https://iconica.nl/ environment: