okTransition method Null safety

Future<void> okTransition(
  1. {required BuildContext context,
  2. required String title,
  3. required String subTitle,
  4. required String message,
  5. IconData? icon,
  6. Color? iconColor,
  7. String? loadingImage,
  8. String? loadingText,
  9. Function? loadingTask,
  10. Function? onSuccess,
  11. dynamic onFail(
    1. {required dynamic error,
    2. required MojoResult result}
    )?,
  12. Widget? target}
)

Implementation

Future<void> okTransition({
  required BuildContext context,
  required String title,
  required String subTitle,
  required String message,
  IconData? icon,
  Color? iconColor,
  String? loadingImage,
  String? loadingText,
  Function? loadingTask,
  Function? onSuccess,
  Function({required dynamic error, required MojoResult result})? onFail,
  Widget? target,
}) async {
  var failed = false;
  if (loadingTask != null) {
    await loadingTransition(
      context: context,
      task: loadingTask,
      image: loadingImage,
      text: loadingText,
      onFail: ({error, required result, message}) {
        failed = true;

        if (onFail != null) {
          onFail(error: error, result: result);
        }
      },
    );
  }

  if (!failed) {
    await Navigator.push(
      context,
      FadeRoute(
        page: OkModal(
          backgroundColour: Theme.of(context).backgroundColor,
          title: title,
          subtitle: subTitle,
          message: message,
          icon: icon,
          iconColour: iconColor,
          success: () {
            Navigator.pop(context);

            if (onSuccess != null) {
              onSuccess();
            }
          },
        ),
      ),
    );
  }
}