hijri_picker
hijri_picker copied to clipboard
Pass weekday number to weekdayBuilder
Sometimes special adjustments need to be made on weekdays. For example, changing the Hijri date after Sunset while keeping the weekday the same as Gregorian date. For these adjustments String day
passed to the weekdayBuilder isn't enough. Weekday number can be very handy for these kind of adjustments. Here's an example:
HijriMonthPicker(
builders: HijriCalendarBuilders(
weekdayBuilder: (context, day, number) {
MaterialLocalizations localizations = MaterialLocalizations.of(context);
int adjustedWeekdayNumber = 0;
if (isAfterDateStartTime(DateTime.now())) {
adjustedWeekdayNumber -= 1;
}
int num = (number + adjustedWeekdayNumber) % 7;
final String weekday = localizations.narrowWeekdays[num];
return Center(
child: Text(weekday),
);
},
),
),
This PR passes the weekday number to weekdayBuilder. This is a breaking change for those who use custom weekdayBuilders.