showPersianDatePicker function Null safety

Future showPersianDatePicker(
  1. BuildContext context,
  2. Future<void> onSubmit(
    1. BuildContext context,
    2. Jalali date
    ),
  3. {int? initYear,
  4. int? initMonth,
  5. int? initDay,
  6. BorderRadiusGeometry? border,
  7. YearDirection yearDirection = YearDirection.backward,
  8. Color backgroundColor = Colors.white,
  9. EdgeInsets margin = EdgeInsets.zero,
  10. ButtonsStyle submitButtonStyle = const ButtonsStyle(backgroundColor: Colors.white, textColor: Colors.black, radius: 5, text: 'تایید', visible: true),
  11. ButtonsStyle cancelButtonStyle = const ButtonsStyle(backgroundColor: Colors.white, textColor: Colors.black, radius: 5, text: 'انصراف', visible: true),
  12. bool validate(
    1. BuildContext context,
    2. Jalali date
    )?}
)

Implementation

Future showPersianDatePicker(
  BuildContext context,
  Future<void> Function(BuildContext context, Jalali date) onSubmit, {
  final int? initYear,
  final int? initMonth,
  final int? initDay,
  final BorderRadiusGeometry? border,
  final YearDirection yearDirection = YearDirection.backward,
  final Color backgroundColor = Colors.white,
  final EdgeInsets margin = EdgeInsets.zero,
  final ButtonsStyle submitButtonStyle = const ButtonsStyle(
    backgroundColor: Colors.white,
    textColor: Colors.black,
    radius: 5,
    text: 'تایید',
    visible: true,
  ),
  final ButtonsStyle cancelButtonStyle = const ButtonsStyle(
    backgroundColor: Colors.white,
    textColor: Colors.black,
    radius: 5,
    text: 'انصراف',
    visible: true,
  ),
  final bool Function(BuildContext context, Jalali date)? validate,
}) async {
  FocusScope.of(context).requestFocus(FocusNode());

  showModalBottomSheet(
      context: context,
      shape: RoundedRectangleBorder(
        borderRadius: border ?? BorderRadius.all(Radius.zero),
      ),
      builder: (context) {
        Jalali j;
        if (initYear != null && initMonth != null && initDay != null) {
          j = Jalali(initYear, initMonth, initDay);
          return Directionality(
            textDirection: TextDirection.rtl,
            child: ClipRRect(
              borderRadius: (border as BorderRadius),
              //BorderRadius.circular(50),
              child: DatePickerModal(
                onSubmit: onSubmit,
                validate: validate,
                initDay: j.day,
                initMonth: j.month,
                initYear: j.year,
                yearDirection: yearDirection,
                backgroundColor: backgroundColor,
                margin: margin,
                submitButtonStyle: submitButtonStyle,
                cancelButtonStyle: cancelButtonStyle,
              ),
            ),
          );
        }
        return Directionality(
          textDirection: TextDirection.rtl,
          child: ClipRRect(
            borderRadius: (border as BorderRadius), //BorderRadius.circular(50),
            child: DatePickerModal(
              onSubmit: onSubmit,
              validate: validate,
              yearDirection: yearDirection,
              backgroundColor: backgroundColor,
              margin: margin,
              submitButtonStyle: submitButtonStyle,
              cancelButtonStyle: cancelButtonStyle,
            ),
          ),
        );
      });
}