show static method
Future<int?>
show({
- required String title,
- String? message,
- required List<
CNAlertAction> actions, - int? preferredActionIndex,
Shows a native alert dialog.
Implementation
static Future<int?> show({
required String title,
String? message,
required List<CNAlertAction> actions,
int? preferredActionIndex,
}) async {
final context = NavigationService.navigatorKey.currentContext;
if (context == null) {
throw StateError('No navigator context available. Make sure NavigationService.navigatorKey is set in your MaterialApp.');
}
// Convert CNAlertAction to BaseAlertAction
final baseActions = actions.map((action) => BaseAlertAction(
title: action.title,
style: _convertToBaseStyle(action.style),
onPressed: action.onPressed,
)).toList();
return await BaseAlert.show(
context: context,
title: title,
message: message,
actions: baseActions,
preferredActionIndex: preferredActionIndex,
);
}