showSyncAlertBox function

dynamic showSyncAlertBox({
  1. required WidgetBuilder builder,
  2. bool barrierDismissible = true,
  3. Color? barrierColor,
  4. String? barrierLabel,
  5. bool useSafeArea = true,
  6. bool useRootNavigator = true,
  7. RouteSettings? routeSettings,
  8. Offset? anchorPoint,
  9. TraversalEdgeBehavior? traversalEdgeBehavior,
})

Shows an alert dialog using showDialog without requiring a BuildContext.

This function is useful for showing alert dialogs from anywhere in the app, even outside the widget tree.

Example:

showSyncAlertBox(
  builder: (BuildContext context) => AlertDialog(
    title: Text('Alert'),
    content: Text('This is an alert dialog.'),
  ),
);

Implementation

showSyncAlertBox({
  required WidgetBuilder builder,
  bool barrierDismissible = true,
  Color? barrierColor,
  String? barrierLabel,
  bool useSafeArea = true,
  bool useRootNavigator = true,
  RouteSettings? routeSettings,
  Offset? anchorPoint,
  TraversalEdgeBehavior? traversalEdgeBehavior,
}) {
  showDialog(
      context: Utils.navigatorKey.currentContext!,
      builder: builder,
      barrierDismissible: barrierDismissible,
      barrierColor: barrierColor,
      barrierLabel: barrierLabel,
      useSafeArea: useSafeArea,
      useRootNavigator: useRootNavigator,
      routeSettings: routeSettings,
      anchorPoint: anchorPoint,
      traversalEdgeBehavior: traversalEdgeBehavior);
}