feature: added call back for whenever the user navigates to a different month

This commit is contained in:
FahadFahim71 2023-07-26 15:36:02 +02:00
parent fa171e956c
commit b040dfc411
4 changed files with 32 additions and 23 deletions

View file

@ -1,3 +1,6 @@
## 3.2.0
- Added call back for whenever the user navigates to a different month
## 3.1.0 ## 3.1.0
- Add compatibility with flutter 3.10 - Add compatibility with flutter 3.10

View file

@ -68,7 +68,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "3.1.1" version: "3.2.0"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:

View file

@ -59,27 +59,32 @@ class DateTimePicker extends StatefulWidget {
final Widget Function(void Function()? onPressed)? final Widget Function(void Function()? onPressed)?
onPreviousPageButtonBuilder; onPreviousPageButtonBuilder;
const DateTimePicker( //final DateTime MonthChangeCallback = void Function(DateTime newMonth);
{super.key, final void Function(DateTime newMonth)? onMonthChanged;
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});
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 @override
State<DateTimePicker> createState() => _DateTimePickerState(); State<DateTimePicker> createState() => _DateTimePickerState();
} }
@ -103,7 +108,6 @@ class _DateTimePickerState extends State<DateTimePicker> {
browsingDate: widget.initialDate ?? DateTime.now(), browsingDate: widget.initialDate ?? DateTime.now(),
selectedDate: widget.initialDate ?? DateTime.now(), selectedDate: widget.initialDate ?? DateTime.now(),
); );
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -164,6 +168,7 @@ class _DateTimePickerState extends State<DateTimePicker> {
_dateTimePickerController.browsingDate.month + 1, _dateTimePickerController.browsingDate.month + 1,
_dateTimePickerController.browsingDate.day, _dateTimePickerController.browsingDate.day,
); );
widget.onMonthChanged?.call(_dateTimePickerController.browsingDate);
}); });
} }
@ -175,6 +180,7 @@ class _DateTimePickerState extends State<DateTimePicker> {
_dateTimePickerController.browsingDate.month - 1, _dateTimePickerController.browsingDate.month - 1,
_dateTimePickerController.browsingDate.day, _dateTimePickerController.browsingDate.day,
); );
widget.onMonthChanged?.call(_dateTimePickerController.browsingDate);
}); });
} }
} }

View file

@ -1,6 +1,6 @@
name: flutter_date_time_picker name: flutter_date_time_picker
description: A Flutter package for date and time picker. description: A Flutter package for date and time picker.
version: 3.1.1 version: 3.2.0
homepage: https://iconica.nl/ homepage: https://iconica.nl/
environment: environment: