showAlert static method

DialogShower showAlert({
  1. String? title,
  2. Widget? icon,
  3. String? text,
  4. double? width,
  5. double? height,
  6. String? buttonLeftText,
  7. String? buttonRightText,
  8. dynamic buttonLeftEvent(
    1. DialogShower dialog
    )?,
  9. dynamic buttonRightEvent(
    1. DialogShower dialog
    )?,
  10. dynamic onOptions(
    1. AnyAlertTextOptions options
    )?,
})

Implementation

static DialogShower showAlert({
  String? title,
  Widget? icon,
  String? text,
  double? width,
  double? height,
  String? buttonLeftText,
  String? buttonRightText,
  Function(DialogShower dialog)? buttonLeftEvent,
  Function(DialogShower dialog)? buttonRightEvent,
  Function(AnyAlertTextOptions options)? onOptions,
}) {
  DialogShower shower = DialogShower();
  AnyAlertTextOptions options = AnyAlertTextOptions();
  width != null ? options.width = width : null;
  height != null ? options.height = height : null;
  buttonLeftText != null ? options.buttonLeftText = buttonLeftText : null;
  buttonRightText != null ? options.buttonRightText = buttonRightText : null;
  buttonLeftEvent != null ? options.buttonLeftEvent = () => buttonLeftEvent.call(shower) : null;
  buttonRightEvent != null ? options.buttonRightEvent = () => buttonRightEvent.call(shower) : null;
  bool isBarrierDismissible = buttonLeftEvent == null && buttonRightEvent == null;
  // customized by caller
  onOptions?.call(options);
  Widget widget = AnyAlertTextWidget(title: title, icon: icon, text: text, options: options);
  DialogWrapper.showWith(shower, widget);
  // rewrite properties
  shower
    ..alignment = Alignment.center
    ..barrierDismissible = isBarrierDismissible
    ..transitionDuration = const Duration(milliseconds: 200)
    ..transitionBuilder = (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
      return ScaleTransition(child: child, scale: Tween(begin: 0.0, end: 1.0).animate(animation));
    };
  return shower;
}