show static method

Future<int?> show({
  1. required String title,
  2. String? message,
  3. required List<CNAlertAction> actions,
  4. 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,
  );
}