Update: 2026-06-23 18:14:22
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user