quickConfirm function
Future<bool>
quickConfirm({
- required BuildContext context,
- TextStyle textStyle = const TextStyle(color: Colors.white),
- Color backgroundColor = Colors.black,
- Widget? title,
- Widget? content,
- EdgeInsets? inputFieldPadding,
- EdgeInsets? inputFieldMargin,
- Language? language,
- Color? overlayColor,
- Text? confirmText,
Implementation
Future<bool> quickConfirm({
required BuildContext context,
TextStyle textStyle = const TextStyle(
color: Colors.white,
),
Color backgroundColor = Colors.black,
Widget? title,
Widget? content,
EdgeInsets? inputFieldPadding,
EdgeInsets? inputFieldMargin,
Language? language,
Color? overlayColor,
Text? confirmText,
})async{
//Confirm a certain action
bool? actionConfirmed = await showDialog(
context: context,
builder: (context)=> AlertDialog(
title: title,
content: content,
actions: [
TextButton(
onPressed: (){
Navigator.pop(context,false);
},
child: TranslatableText(
options: [
TranslateOption(language: Languages.english, text: "cancel"),
TranslateOption(language: Languages.spanish, text: "cancelar"),
],
displayLanguage: language ?? Languages.english,
),
style: ButtonStyle(
overlayColor: MaterialStateProperty.all(backgroundColor),
),
),
TextButton(
onPressed: (){
Navigator.pop(context,true);
},
child: confirmText ?? TranslatableText(
options: [
TranslateOption(language: Languages.english, text: "Ok"),
TranslateOption(language: Languages.spanish, text: "De acuerdo"),
],
displayLanguage: language ?? Languages.english,
style: textStyle,
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(backgroundColor),
overlayColor: overlayColor == null ? null : MaterialStateProperty.all(overlayColor.withOpacity(0.5)),
),
),
],
),
);
return actionConfirmed ?? false;
}