diff --git a/.gitignore b/.gitignore index fcfa202c..c8887dcd 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,4 @@ metrics coverage_report coverage +example/macos/Flutter/GeneratedPluginRegistrant.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 166aed08..e018ca0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.0.4] +### 🔄 Updated 🔄 +* Added `initialTime` parameter to `MacosTimePicker`, allowing to set an initial time for the picker.This provides more customization options for selecting time. + ## [2.0.3] ### 🛠️ Fixed 🛠️ * Fixed a bug that caused the sidebar to appear darker than intended. diff --git a/lib/src/selectors/date_picker.dart b/lib/src/selectors/date_picker.dart index 2b3cd9b0..25515a7d 100644 --- a/lib/src/selectors/date_picker.dart +++ b/lib/src/selectors/date_picker.dart @@ -21,7 +21,7 @@ enum DatePickerStyle { /// {template onDateChanged} /// The action to perform when a new date is selected. /// {endtemplate} -typedef OnDateChanged = Function(DateTime date); +typedef OnDateChanged = void Function(DateTime date); /// {template macosDatePicker} /// A [MacosDatePicker] lets the user choose a date. diff --git a/lib/src/selectors/time_picker.dart b/lib/src/selectors/time_picker.dart index 815b23d5..47b4bb15 100644 --- a/lib/src/selectors/time_picker.dart +++ b/lib/src/selectors/time_picker.dart @@ -20,8 +20,8 @@ enum TimePickerStyle { /// {template onTimeChanged} /// The action to perform when a new time is selected. -/// {endtemplate} -typedef OnTimeChanged = Function(TimeOfDay time); +/// {end-template} +typedef OnTimeChanged = void Function(TimeOfDay time); /// {template macosTimePicker} /// A [MacosTimePicker] lets the user choose a time. @@ -36,15 +36,21 @@ typedef OnTimeChanged = Function(TimeOfDay time); /// /// The [onTimeChanged] callback passes through the user's selected time, and /// must be provided. -/// {endtemplate} +/// {end-template} class MacosTimePicker extends StatefulWidget { /// {@macro macosTimePicker} const MacosTimePicker({ super.key, required this.onTimeChanged, + this.initialTime, this.style = TimePickerStyle.combined, }); + /// Set an initial date for the picker. + /// + /// Defaults to `TimeOfDay.now()`. + final TimeOfDay? initialTime; + /// The [TimePickerStyle] to use. /// /// Defaults to [TimePickerStyle.combined]. @@ -58,7 +64,7 @@ class MacosTimePicker extends StatefulWidget { } class _MacosTimePickerState extends State { - final _initialTime = TimeOfDay.now(); + late final _initialTime = widget.initialTime ?? TimeOfDay.now(); late int _selectedHour; late int _selectedMinute; late DayPeriod _selectedPeriod;