A Persian DateTime picker inspired by Material Design's DateTime picker and built upon the shamsi_date library.
- 🌟 Fully supports Persian (Jalali) calendar
- 🛠 Built using the stable and widely used
shamsi_date
library - 📱 Compatible with Material Design standards
- 🧑💻 Simple integration with Flutter
To use the Persian DateTime Picker, add the package to your pubspec.yaml
:
dependencies:
persian_datetime_picker: <latest_version>
Then, import it in your Dart code:
import 'package:persian_datetime_picker/persian_datetime_picker.dart';
Jalali picked = await showPersianDatePicker(
context: context,
initialDate: Jalali.now(),
firstDate: Jalali(1385, 8),
lastDate: Jalali(1450, 9),
);
var label = picked.formatFullDate();
var picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
var label = picked.persianFormat(context);
Jalali pickedDate = await showModalBottomSheet<Jalali>(
context: context,
builder: (context) {
Jalali tempPickedDate;
return Container(
height: 250,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CupertinoButton(
child: Text('لغو', style: TextStyle(fontFamily: 'Dana')),
onPressed: () => Navigator.of(context).pop(),
),
CupertinoButton(
child: Text('تایید', style: TextStyle(fontFamily: 'Dana')),
onPressed: () => Navigator.of(context).pop(tempPickedDate ?? Jalali.now()),
),
],
),
Divider(height: 0, thickness: 1),
Expanded(
child: CupertinoTheme(
data: CupertinoThemeData(
textTheme: CupertinoTextThemeData(dateTimePickerTextStyle: TextStyle(fontFamily: "Dana")),
),
child: PCupertinoDatePicker(
mode: PCupertinoDatePickerMode.dateAndTime,
onDateTimeChanged: (Jalali dateTime) {
tempPickedDate = dateTime;
},
),
),
),
],
),
);
},
);
var picked = await showPersianDateRangePicker(
context: context,
initialEntryMode: PDatePickerEntryMode.input,
initialDateRange: JalaliRange(
start: Jalali(1400, 1, 2),
end: Jalali(1400, 1, 10),
),
firstDate: Jalali(1385, 8),
lastDate: Jalali(1450, 9),
);
Pull requests and feedback are always welcome!
Feel free to reach out at [email protected] or connect with me on LinkedIn.
Banner designed by Nader Mozaffari