Persian Modal Date Picker

Persian_Modal_Date_Picker is a modal date picker which is used to select Jalali date.

  • Jalali Date
  • Set initial date
  • Forward/backward selector
  • Use custom validator for date
image

Usage

await showPersianDatePicker(
      context,
      (context, Date date) async {
        setState(() {
          _selectedDate = date;
        });
        Navigator.of(context).pop();
      },
      forwardYear: true,
      border: BorderRadius.only(
          topRight: Radius.circular(15), topLeft: Radius.circular(15)),
      validate: (ctx, date) {
        return date.year < 1402;
      },
      submitButtonStyle: defaultButtonsStyle.copyWith(
        text: 'انتخاب',
        backgroundColor: Colors.blueAccent,
        radius: 10,
      ),
    );

Parameters

showPersianDatePicker(context, onSubmit, {/* ohter optional parameter*/});

ParametersTypeIs RequiredDescription
contextBuildContextYes
onSubmitFuture Function(BuildContext context, Jalali date)YesCallback function when a date is selected
initYearintNoInitial the Date Picker with optional date. Note that, this works when initMonth and initDay are provided.
initMonthintNoAs the same as initYear
initDayintNoAs the same as initYear
borderBorderRadiusGeometryNoOptional BorderRadius
yearDirectionYearDirectionNoselect year direction. Values are YearDirection.backward, YearDirection.forward and YearDirection.both
backgroundColorColorNo
marginEdgeInsetsNoDate Picker margin
submitButtonStyleButtonsStyleNoStyle of submit bottom
cancelButtonStyleButtonsStyleNoStyle of cancel bottom
validatebool Function(BuildContext context, Jalali date)NoYou can provide a validate function to check if the selected date is correct or not

The ButtonsStyle class

ParametersTypeIs RequiredDescription
backgroundColorColorNoDefault value is Colors.white
textColorColorNoDefault value is Colors.black
radiusdoubleNoDefault value is 5.0
visibleboolNoDefault value is true
textStringYesDefault value is ''

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Libraries

button
persian_date_picker