diff --git a/siro_rider/lib/views/widgets/error_snakbar.dart b/siro_rider/lib/views/widgets/error_snakbar.dart index cb141e3..5e7045f 100644 --- a/siro_rider/lib/views/widgets/error_snakbar.dart +++ b/siro_rider/lib/views/widgets/error_snakbar.dart @@ -240,12 +240,20 @@ class _SnackContentState extends State<_SnackContent> // ───────────────────────────────────────────────────────────────────────────── // Internal dispatcher — single source of truth // ───────────────────────────────────────────────────────────────────────────── +int _retryCount = 0; + SnackbarController? _show(_SnackVariant variant, String message) { // Prevent crash if Navigator or Overlay context is not yet initialized at early startup if (Get.context == null || Get.overlayContext == null || Get.key.currentState?.overlay == null) { debugPrint("⚠️ Cannot show snackbar: Overlay/Navigator is not ready yet. Message: $message"); + // Retry up to 3 times after the next frame (handles race condition during route transitions) + if (_retryCount < 3) { + _retryCount++; + WidgetsBinding.instance.addPostFrameCallback((_) => _show(variant, message)); + } return null; } + _retryCount = 0; try { // Removed Get.closeCurrentSnackbar() because it causes async LateInitializationError in GetX at early startup