showAlert static method
DialogShower
showAlert({
- String? title,
- Widget? icon,
- String? text,
- double? width,
- double? height,
- String? buttonLeftText,
- String? buttonRightText,
- dynamic buttonLeftEvent(
- DialogShower dialog
- dynamic buttonRightEvent(
- DialogShower dialog
- dynamic onOptions(
- 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;
}