showAlert function
void
showAlert({
- BuildContext? context,
- String? title,
- required Widget content,
- List<
Widget> ? actions, - EdgeInsetsGeometry? titleBoxPadding,
- EdgeInsetsGeometry? titlePadding,
- EdgeInsetsGeometry? contentPadding,
- Color? titleColor,
- Color? titleBorderColor,
- Color? backgroundColor,
- double? titleBorderSize,
Implementation
void showAlert({
BuildContext? context,
String? title,
required Widget content,
List<Widget>? actions,
EdgeInsetsGeometry? titleBoxPadding,
EdgeInsetsGeometry? titlePadding,
EdgeInsetsGeometry? contentPadding,
Color? titleColor,
Color? titleBorderColor,
Color? backgroundColor,
double? titleBorderSize,
}) {
if (context == null && (!state.isContextLoaded || !state.appContext.mounted)) {
assert(false,
"App Context was not loaded or not mounted");
return;
}
if (context != null && !context.mounted) {
assert(false,
"Provided Context was not loaded or not mounted");
return;
}
context = context?? state.appContext;
Widget? titleWidget;
if (title != null && title.isNotEmpty) {
titleWidget = Column(
children: [
Row(
children: [
Padding(
padding: titlePadding?? const EdgeInsets.all(0),
child: Text(
style: TextStyle(
color: titleColor,
),
title
),
),
],
),
Divider(
thickness: titleBorderSize?? 1,
color: titleBorderColor?? Colors.transparent,
)
],
);
}
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: titleWidget,
content: content,
actions: actions,
titlePadding: titleBoxPadding,
contentPadding: contentPadding,
backgroundColor: backgroundColor,
);
},
);
}