samore_weekenddatetime_picker 0.0.1 copy "samore_weekenddatetime_picker: ^0.0.1" to clipboard
samore_weekenddatetime_picker: ^0.0.1 copied to clipboard

A Flutter package that provides a customizable weekend date-time picker for selecting dates and times easily.

Datetime picker with weekends disabled

Features #

picker

Getting started #

install

Usage #

ElevatedButton( onPressed: () async { final DateTime? pickedDateTime = await showDialog( context: context, builder: (BuildContext context) { DateTime currentDate = DateTime.now(); while (!selectableDayPredicate(currentDate)) { currentDate = currentDate.add(const Duration(days: 1)); } return StatefulBuilder( builder: (context, setState) { return AlertDialog( title: const Text("Select Date and Time"), content: Column( mainAxisSize: MainAxisSize.min, children: [ // Date Picker SizedBox( width: 500, child: CalendarDatePicker( initialDate: currentDate, firstDate: DateTime.now() .subtract(const Duration(days: 365)), lastDate: DateTime.now().add(const Duration(days: 365)), selectableDayPredicate: selectableDayPredicate, onDateChanged: (DateTime newDate) { setState(() { currentDate = newDate; }); }, ), ), // Time Picker SizedBox( width: 500, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ TextButton( onPressed: () async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: selectedTime ?? TimeOfDay.now(), ); if (pickedTime != null) { setState(() { selectedTime = pickedTime; }); } }, child: const Text( 'Select Time', style: TextStyle(color: Colors.blue), ), ), Text( selectedTime != null ? '${selectedTime!.hour}:${selectedTime!.minute} ${selectedTime!.period == DayPeriod.am ? 'AM' : 'PM'}' : DateFormat('hh:mm a').format(currentDate), style: const TextStyle(fontSize: 16), ), ], ), ), ], ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text('Cancel'), ), TextButton( onPressed: () { if (selectedTime != null) { currentDate = DateTime( currentDate.year, currentDate.month, currentDate.day, selectedTime!.hour, selectedTime!.minute, ); } Navigator.of(context).pop(currentDate); }, child: const Text('OK'), ), ], ); }, ); }, ); if (pickedDateTime != null) { setState(() { selectedDateTime = pickedDateTime; }); } }, child: Text(selectedDateTime != null ? DateFormat('dd/MM/yyyy hh:mm a').format(selectedDateTime!) : 'Select Date and Time'), ),

Additional information #

2
likes
0
points
42
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that provides a customizable weekend date-time picker for selecting dates and times easily.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, intl

More

Packages that depend on samore_weekenddatetime_picker