yShowStatefulDialog function

void yShowStatefulDialog({
  1. required dynamic alertBuilder(
    1. BuildContext pageContext,
    2. BuildContext? dialogContext,
    3. BuildContext statefulContext,
    4. StateSetter setDialogState,
    ),
  2. bool dismissible = true,
  3. BuildContext? context,
})

Implementation

void yShowStatefulDialog({required Function(BuildContext pageContext, BuildContext? dialogContext, BuildContext statefulContext, StateSetter setDialogState) alertBuilder, bool dismissible = true, BuildContext? context}) {
  showDialog(
    context: context ?? yPages.last.context,
    barrierDismissible: dismissible,
    builder: (dialogContext) {
      if (!dismissible) _dialogContext = dialogContext;
      return WillPopScope(
        onWillPop: () => Future.value(dismissible),
        child: StatefulBuilder(
          builder: (statefulContext, setDialogState) => alertBuilder(context ?? yPages.last.context, dismissible ? dialogContext : null, statefulContext, setDialogState),
        ),
      );
    },
  );
}