showQudsYesNoDialog function
Future<void>
showQudsYesNoDialog(
- BuildContext context, {
- Widget? child,
- Widget builder(
- BuildContext context
- EdgeInsets insetPadding = _defaultDialogInsetPadding,
- Widget? title,
- List<
Widget> ? leadingActions, - AlignmentGeometry alignment = Alignment.center,
- Color? backgroundColor,
- BorderRadius? borderRadius,
- String yesText = 'Yes',
- String noText = 'No',
- Color? yesColor,
- Color? barrierColor,
- bool withBlur = false,
- Color? noColor,
- Function? onYesPressed,
- Function? onNoPressed,
- bool withAnimatedSize = true,
Show two actions dialog with Yes
- No
.
Implementation
Future<void> showQudsYesNoDialog(BuildContext context,
{Widget? child,
Widget Function(BuildContext context)? builder,
EdgeInsets insetPadding = _defaultDialogInsetPadding,
Widget? title,
List<Widget>? leadingActions,
AlignmentGeometry alignment = Alignment.center,
Color? backgroundColor,
BorderRadius? borderRadius,
String yesText = 'Yes',
String noText = 'No',
Color? yesColor,
Color? barrierColor,
bool withBlur = false,
Color? noColor,
Function? onYesPressed,
Function? onNoPressed,
bool withAnimatedSize = true}) async {
var result = await showQudsDialog(context,
child: child,
builder: builder,
withBlur: withBlur,
barrierColor: barrierColor,
insetPadding: insetPadding,
title: title,
leadingActions: leadingActions,
alignment: alignment,
backgroundColor: backgroundColor,
withAnimatedSize: withAnimatedSize,
actions: [
TextButton(
style: yesColor == null
? null
: ButtonStyle(
foregroundColor: MaterialStateProperty.all(yesColor)),
onPressed: () {
Navigator.maybePop(context, 'yes');
},
child: Text(yesText)),
TextButton(
style: noColor == null
? null
: ButtonStyle(
foregroundColor: MaterialStateProperty.all(noColor)),
onPressed: () {
Navigator.maybePop(context, 'no');
},
child: Text(noText)),
]);
switch (result) {
case 'yes':
onYesPressed?.call();
break;
case 'no':
onNoPressed?.call();
break;
}
}