showAlertDialog function
Future<bool>
showAlertDialog(
- BuildContext? context,
- String title,
- String content,
- List<
Widget> actions, { - TextStyle? titleStyle,
- TextStyle? contentStyle,
- MainAxisAlignment? actionsAlignment,
- Color? backgroundColor,
- Brightness? backgroundBrightness,
Implementation
Future<bool> showAlertDialog(
BuildContext? context,
String title,
String content,
List<Widget> actions, {
TextStyle? titleStyle,
TextStyle? contentStyle,
MainAxisAlignment? actionsAlignment,
Color? backgroundColor,
Brightness? backgroundBrightness,
}) async {
if (!(context?.mounted ?? false)) {
ZegoLoggerService.logInfo(
'show dialog error, context is not mounted, '
'context:$context, '
'title:$title, '
'content:$content, '
'actions:$actions, ',
tag: 'uikit',
subTag: 'dialogs',
);
return false;
}
var result = false;
try {
result = await showDialog(
context: context!,
barrierDismissible: false,
builder: (BuildContext context) {
return CupertinoTheme(
data: CupertinoThemeData(
brightness: backgroundBrightness ?? Brightness.dark,
),
child: CupertinoAlertDialog(
title: Text(
title,
textAlign: TextAlign.center,
style: titleStyle ??
TextStyle(
fontSize: 30.0.zR,
fontWeight: FontWeight.bold,
color: const Color(0xff2A2A2A),
),
),
content: Text(
content,
textAlign: TextAlign.center,
style: contentStyle ??
TextStyle(
fontSize: 28.0.zR,
color: const Color(0xff2A2A2A),
),
),
actions: actions,
),
);
},
) ??
false;
} catch (e) {
ZegoLoggerService.logError(
'show dialog error, $e, '
'context;$context, ',
tag: 'uikit',
subTag: 'dialogs',
);
}
return result;
}