changeAlertType method

void changeAlertType({
  1. required StylishDialogType alertType,
  2. Widget? title,
  3. Widget? content,
  4. @Deprecated('Use `confirmButton` instead. will be removed soon') String? confirmText,
  5. @Deprecated('Use `cancelButton` instead. will be removed soon') String? cancelText,
  6. @Deprecated('Use `confirmButton` instead. will be removed soon') VoidCallback? confirmPressEvent,
  7. @Deprecated('Use `cancelButton` instead. will be removed soon') VoidCallback? cancelPressEvent,
  8. Widget? confirmButton,
  9. Widget? cancelButton,
})

Call changeAlertType function to change the alert type of the current dialog

StylishDialog dialog = StylishDialog(
  context: context,
  alertType: StylishDialogType.PROGRESS,
  ...
);
...

dialog.changeAlertType(
  alertType: StylishDialogType.WARNING,
  ...
);

Implementation

void changeAlertType({
  required StylishDialogType alertType,

  ///title widget of the dialog
  Widget? title,

  ///content widget of the dialog
  Widget? content,
  @Deprecated('Use `confirmButton` instead. will be removed soon')
      String? confirmText,
  @Deprecated('Use `cancelButton` instead. will be removed soon')
      String? cancelText,
  @Deprecated('Use `confirmButton` instead. will be removed soon')
      VoidCallback? confirmPressEvent,
  @Deprecated('Use `cancelButton` instead. will be removed soon')
      VoidCallback? cancelPressEvent,

  ///Use this to add confirm button widget.
  ///To assign press event on non-clickable widgets like
  ///```dart
  /// Containter(), Text() etc.
  ///```
  ///Wrap you widget with
  ///```dart
  ///GestureDetector() or InkWell()
  ///```
  Widget? confirmButton,

  ///Use this to add cancel button widget.
  ///To assign press event on non-clickable widgets like
  ///```dart
  /// Containter(), Text() etc.
  ///```
  ///Wrap you widget with
  ///```dart
  ///GestureDetector(
  /// onTap: (){
  ///
  /// },
  ///
  /// child: ...
  ///
  ///),
  /// //or
  ///
  ///InkWell(
  /// onTap: (){
  ///
  /// },
  ///
  /// child: ...
  ///
  ///),
  ///```
  Widget? cancelButton,
}) {
  _stateSetter(() {
    this.title = title;
    this.content = content;
    this.confirmText = confirmText;
    this.cancelText = cancelText;
    this.confirmPressEvent = confirmPressEvent;
    this.cancelPressEvent = cancelPressEvent;
    this.confirmButton = confirmButton;
    this.cancelButton = cancelButton;

    _changeAlert = alertType;

    controller?.setValue = DialogStatus.Changed;

    _buildDialogUI();
  });
}