showPopUp method
void
showPopUp({
- required BuildContext context,
- EdgeInsetsGeometry? padding,
- Color? background,
- Widget? child,
- bool withActions = false,
- bool roundedButtons = false,
- Function? action1,
- Function? action2,
- String? text1,
- String? text2,
Show a popUp from anywhere (with context) with the defaultPopUp
(from the AppDelegate) or a custom (child
)
Implementation
void showPopUp({
required BuildContext context,
EdgeInsetsGeometry? padding,
Color? background,
Widget? child,
bool withActions = false,
bool roundedButtons = false,
Function? action1,
Function? action2,
String? text1,
String? text2,
}) {
showDialog(
context: context,
builder: (context) {
return Dialog(
backgroundColor: background ?? getColor("Dark"),
child: Padding(
padding: padding ?? const EdgeInsets.all(16.0),
child: withActions
? Column(
mainAxisSize: MainAxisSize.min,
children: (child != null
? [child]
: defaultPopUp.value) +
[
const SizedBox(
height: 16,
)
] +
[
roundedButtons
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
RoundedButton(
text: text1!,
onPressed: () {
action1 != null
? action1()
: Navigator.pop(context);
},
width: text2 != null
? MediaQuery.of(context)
.size
.width /
3
: MediaQuery.of(context)
.size
.width /
2),
if (text2 != null) ...{
RoundedButton(
text: text2,
onPressed: () {
action2 != null
? action2()
: Navigator.pop(context);
},
width: MediaQuery.of(context)
.size
.width /
3)
},
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
AutoTextButton(text1 ?? "Cancel",
onPressed: () {
action1 != null
? action1()
: Navigator.pop(context);
}),
const SizedBox(
width: 8.0,
),
AutoTextButton(text2 ?? "Okay",
onPressed: () {
action2 != null
? action2()
: Navigator.pop(context);
}),
],
)
],
)
: child ??
Column(
children: defaultPopUp.value,
)),
);
});
}