showConfirmationDialog function
dynamic
showConfirmationDialog(
- BuildContext context, {
- Widget? transitionAnimation,
- String negativeBtnText = kNo,
- String positiveBtnText = kYes,
- bool barrierDismissible = false,
- Color dividerColor = Colors.blue,
- Color negativeBtnColor = Colors.red,
- Color positiveBtnColor = Colors.blue,
- TextAlign descTextAlign = TextAlign.center,
- TextAlign titleTextAlign = TextAlign.center,
- Duration transitionDuration = const Duration(milliseconds: 400),
- DialogAnimationType dialogAnimationType = DialogAnimationType.grow,
- TextStyle descStyle = const TextStyle(fontSize: 16, letterSpacing: 0.27, color: Colors.black),
- TextStyle titleStyle = const TextStyle(fontSize: 18, letterSpacing: 0.27, fontWeight: FontWeight.bold),
- TextStyle positiveBtnStyle = const TextStyle(fontSize: 18, letterSpacing: 0.27, fontWeight: FontWeight.w400),
- TextStyle negativeBtnStyle = const TextStyle(fontSize: 18, letterSpacing: 0.27, fontWeight: FontWeight.w400),
- required String title,
- required String description,
- required VoidCallback onPositivePressed,
This method will show a dialog box with custom UI and animation
Implementation
showConfirmationDialog(
BuildContext context, {
Widget? transitionAnimation,
String negativeBtnText = kNo,
String positiveBtnText = kYes,
bool barrierDismissible = false,
Color dividerColor = Colors.blue,
Color negativeBtnColor = Colors.red,
Color positiveBtnColor = Colors.blue,
TextAlign descTextAlign = TextAlign.center,
TextAlign titleTextAlign = TextAlign.center,
Duration transitionDuration = const Duration(milliseconds: 400),
DialogAnimationType dialogAnimationType = DialogAnimationType.grow,
TextStyle descStyle = const TextStyle(fontSize: 16, letterSpacing: 0.27, color: Colors.black),
TextStyle titleStyle = const TextStyle(fontSize: 18, letterSpacing: 0.27, fontWeight: FontWeight.bold),
TextStyle positiveBtnStyle = const TextStyle(fontSize: 18, letterSpacing: 0.27, fontWeight: FontWeight.w400),
TextStyle negativeBtnStyle = const TextStyle(fontSize: 18, letterSpacing: 0.27, fontWeight: FontWeight.w400),
required String title,
required String description,
required VoidCallback onPositivePressed,
}) {
return showGeneralDialog(
context: context,
barrierLabel: '',
barrierDismissible: barrierDismissible,
transitionDuration: transitionDuration,
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, animation, secondaryAnimation, child) {
switch (dialogAnimationType) {
case DialogAnimationType.grow:
return Animations.grow(animation, child);
case DialogAnimationType.fromTop:
return Animations.fromTop(animation, child);
case DialogAnimationType.fromLeft:
return Animations.fromLeft(animation, child);
case DialogAnimationType.fromRight:
return Animations.fromRight(animation, child);
case DialogAnimationType.fromBottom:
return Animations.fromBottom(animation, child);
default:
return Animations.grow(animation, child);
}
},
pageBuilder: (BuildContext context, animation, secondaryAnimation) {
return _CustomConfirmDialog(
title: title,
descStyle: descStyle,
titleStyle: titleStyle,
description: description,
dividerColor: dividerColor,
descTextAlign: descTextAlign,
titleTextAlign: titleTextAlign,
positiveBtnText: positiveBtnText,
negativeBtnText: negativeBtnText,
positiveBtnColor: positiveBtnColor,
negativeBtnColor: negativeBtnColor,
positiveBtnStyle: positiveBtnStyle,
negativeBtnStyle: negativeBtnStyle,
onPositivePressed: onPositivePressed,
);
},
);
}