A customizable Material Design Hebrew date picker for Flutter applications, supporting both single date and date range selection. This package provides a culturally appropriate date selection experience for apps targeting Hebrew/English-speaking users.
- Hebrew calendar support with accurate date calculations
- Single date and date range selection modes
- Customizable themes
- Support for both Hebrew and Gregorian date display
- Responsive design for various screen sizes
- Right-to-left (RTL) support for Hebrew text
- Today highlighting
- Year selection mode
- Customizable color scheme and typography
Add this to your package's pubspec.yaml
file:
dependencies:
material_hebrew_date_picker: 1.0.0+7
Then run:
$ flutter pub get
Import the package in your Dart code:
import 'package:material_hebrew_date_picker/material_hebrew_date_picker.dart';
void _showSingleDatePicker() async {
await showMaterialHebrewDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2100),
hebrewFormat: true,
onDateChange: (date) {
print('Date changed: $date');
},
onConfirmDate: (date) {
print('Date confirmed: $date');
// Handle the confirmed date
},
);
}
void _showDateRangePicker() async {
final DateTimeRange? result = await showMaterialHebrewDateRangePicker(
context: context,
firstDate: DateTime.now(),
lastDate: DateTime.now().add(Duration(days: 365)),
hebrewFormat: true,
);
if (result != null) {
print('Selected range: ${result.start} to ${result.end}');
// Handle the selected date range
}
}
While not required, you may want to use the kosher_dart
package for advanced Hebrew date functionality. Here's an example:
import 'package:kosher_dart/kosher_dart.dart';
void _showSingleDatePicker() {
showMaterialHebrewDatePicker(
context: context,
initialDate: _selectedDate ?? DateTime.now(),
firstDate: JewishDate().getGregorianCalendar(),
lastDate: JewishDate().getGregorianCalendar().add(const Duration(days: 30)),
hebrewFormat: false,
onDateChange: (date) {
print('Date changed: $date');
},
onConfirmDate: (date) {
print('Date confirmed: $date');
setState(() {
_selectedDate = date;
});
},
);
}
To use kosher_dart
, add it to your pubspec.yaml
:
dependencies:
kosher_dart: ^2.0.16 # Use the latest version
You can customize the appearance of the date picker using the HebrewDatePickerTheme
class:
HebrewDatePickerTheme customTheme = HebrewDatePickerTheme(
primaryColor: Colors.blue,
onPrimaryColor: Colors.white,
surfaceColor: Colors.white,
onSurfaceColor: Colors.black87,
disabledColor: Colors.grey,
selectedColor: Colors.blue,
todayColor: Colors.orange,
headerTextStyle: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
bodyTextStyle: TextStyle(fontSize: 14),
weekdayTextStyle: TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
);
showMaterialHebrewDatePicker(
// ... other parameters
theme: customTheme,
);
The package supports both Hebrew and English languages. The language is determined by the hebrewFormat
parameter:
-
When
hebrewFormat
istrue
, the picker displays in Hebrew: -
When
hebrewFormat
isfalse
, the picker displays in English:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE.md file for details.
If you have any questions or run into any problems, please open an issue in the GitHub repository.