showDefault method
void
showDefault({
- String? title,
- Color? titleColor,
- double? titleSize,
- FontWeight? titleWeight,
- String? message,
- Color? messageColor,
- double? messageSize,
- FontWeight? messageWeight,
- String? buttonOneText = '',
- Color? buttonOneTextColor,
- double? buttonOneTextSize,
- FontWeight? buttonOneTextWeight,
- Color? buttonOneColor,
- RadiusPlus? buttonOneRadius,
- dynamic buttonOneCallback()?,
- String? buttonTwoText = '',
- Color? buttonTwoTextColor,
- double? buttonTwoTextSize,
- FontWeight? buttonTwoTextWeight,
- Color? buttonTwoColor,
- RadiusPlus? buttonTwoRadius,
- dynamic buttonTwoCallback()?,
- double? buttonsHeight,
- EdgeInsetsGeometry? padding,
- Color? barrierColor,
- bool barrierDismissible = true,
- bool closeKeyboardWhenOpen = true,
- RadiusPlus? radius,
- BorderPlus? border,
- double elevation = 1,
- double elementsSpacing = 16,
- double? screenHorizontalMargin,
Shows default Dialog with some customizations
Implementation
void showDefault({
// title
String? title,
Color? titleColor,
double? titleSize,
FontWeight? titleWeight,
// message
String? message,
Color? messageColor,
double? messageSize,
FontWeight? messageWeight,
// button one
String? buttonOneText = '',
Color? buttonOneTextColor,
double? buttonOneTextSize,
FontWeight? buttonOneTextWeight,
Color? buttonOneColor,
RadiusPlus? buttonOneRadius,
Function()? buttonOneCallback,
// buttonTwo
String? buttonTwoText = '',
Color? buttonTwoTextColor,
double? buttonTwoTextSize,
FontWeight? buttonTwoTextWeight,
Color? buttonTwoColor,
RadiusPlus? buttonTwoRadius,
Function()? buttonTwoCallback,
// others
double? buttonsHeight,
EdgeInsetsGeometry? padding,
Color? barrierColor,
bool barrierDismissible = true,
bool closeKeyboardWhenOpen = true,
RadiusPlus? radius,
BorderPlus? border,
double elevation = 1,
double elementsSpacing = 16,
double? screenHorizontalMargin,
}) {
if (closeKeyboardWhenOpen == true) {
utilsPlus.closeKeyboard();
}
showDialog(
context: navigatorPlus.currentContext!,
barrierColor: barrierColor,
barrierDismissible: buttonOneText == null ? true : barrierDismissible,
builder: (context) {
Widget? buttonsContent;
if (buttonOneText!.isNotNullOrEmpty &&
buttonTwoText!.isNotNullOrEmpty) {
buttonsContent = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: _createButton(
buttonOneText,
buttonOneTextColor,
buttonOneTextSize,
buttonOneTextWeight,
buttonsHeight,
buttonOneColor,
buttonOneRadius,
buttonOneCallback,
),
),
SizedBox(
width: elementsSpacing,
),
Expanded(
child: _createButton(
buttonTwoText,
buttonTwoTextColor,
buttonTwoTextSize,
buttonTwoTextWeight,
buttonsHeight,
buttonTwoColor,
buttonTwoRadius,
buttonTwoCallback,
),
)
],
);
} else if (buttonOneText.isNotNullOrEmpty) {
buttonsContent = _createButton(
buttonOneText,
buttonOneTextColor,
buttonOneTextSize,
buttonOneTextWeight,
buttonsHeight,
buttonOneColor,
buttonOneRadius,
buttonOneCallback,
);
} else if (buttonTwoText!.isNotNullOrEmpty) {
buttonsContent = _createButton(
buttonTwoText,
buttonTwoTextColor,
buttonTwoTextSize,
buttonTwoTextWeight,
buttonsHeight,
buttonTwoColor,
buttonTwoRadius,
buttonTwoCallback,
);
}
TextPlus? titleWidget;
if (title != null) {
titleWidget = TextPlus(
title,
color: titleColor ?? Colors.black,
fontSize: titleSize ?? 20,
fontWeight: titleWeight ?? FontWeight.w700,
textAlign: TextAlign.center,
textOverflow: TextOverflow.ellipsis,
);
}
TextPlus? messageWidget;
if (message != null) {
messageWidget = TextPlus(
message,
color: messageColor ?? Colors.grey,
fontSize: messageSize ?? 16,
fontWeight: messageWeight ?? FontWeight.normal,
textAlign: TextAlign.center,
// textOverflow: TextOverflow.ellipsis,
);
}
var dialogContent = Padding(
padding: padding ?? EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
titleWidget ?? SizedBox.shrink(),
messageWidget != null
? SizedBox(
height: elementsSpacing,
)
: SizedBox.shrink(),
messageWidget ?? SizedBox.shrink(),
buttonsContent != null
? SizedBox(
height: elementsSpacing,
)
: SizedBox.shrink(),
buttonsContent ?? SizedBox.shrink(),
],
),
);
return _createDialog(
dialogContent,
elevation,
radius ?? RadiusPlus.all(20),
border,
screenHorizontalMargin,
);
},
);
}