Update: 2026-06-23 18:12:45
This commit is contained in:
@@ -250,6 +250,20 @@ SnackbarController? _show(_SnackVariant variant, String message) {
|
||||
try {
|
||||
// Removed Get.closeCurrentSnackbar() because it causes async LateInitializationError in GetX at early startup
|
||||
|
||||
// We use ScaffoldMessenger instead of Get.snackbar because GetX's snackbar
|
||||
// throws synchronous "No Overlay widget found" FlutterErrors when the
|
||||
// Overlay isn't perfectly mounted, crashing the app globally.
|
||||
final context = Get.context;
|
||||
if (context == null) return null;
|
||||
|
||||
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||
if (messenger == null) {
|
||||
debugPrint("⚠️ Cannot show snackbar: ScaffoldMessenger not found. Message: $message");
|
||||
return null;
|
||||
}
|
||||
|
||||
messenger.clearSnackBars(); // Prevent stacking
|
||||
|
||||
switch (variant.haptic) {
|
||||
case HapticFeedbackType.light:
|
||||
HapticFeedback.lightImpact();
|
||||
@@ -259,27 +273,20 @@ SnackbarController? _show(_SnackVariant variant, String message) {
|
||||
HapticFeedback.selectionClick();
|
||||
}
|
||||
|
||||
return Get.snackbar(
|
||||
'',
|
||||
'',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
backgroundColor: Colors.transparent,
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
duration: const Duration(seconds: 4),
|
||||
animationDuration: const Duration(milliseconds: 380),
|
||||
barBlur: 0,
|
||||
overlayBlur: 0,
|
||||
overlayColor: Colors.transparent,
|
||||
isDismissible: true,
|
||||
dismissDirection: DismissDirection.up,
|
||||
forwardAnimationCurve: Curves.easeOutCubic,
|
||||
reverseAnimationCurve: Curves.easeInCubic,
|
||||
snackStyle: SnackStyle.FLOATING,
|
||||
userInputForm: Form(
|
||||
child: _SnackContent(message: message, variant: variant),
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: _SnackContent(message: message, variant: variant),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 4),
|
||||
dismissDirection: DismissDirection.up,
|
||||
),
|
||||
);
|
||||
|
||||
return null; // We return null since we no longer use Get.snackbar's controller
|
||||
} catch (e) {
|
||||
debugPrint("⚠️ Exception caught showing snackbar: $e");
|
||||
return null;
|
||||
|
||||
@@ -40,7 +40,7 @@ class GetQueue {
|
||||
var item = _queue.removeAt(0);
|
||||
try {
|
||||
item.completer.complete(await item.job());
|
||||
} on Exception catch (e) {
|
||||
} catch (e) {
|
||||
item.completer.completeError(e);
|
||||
}
|
||||
_active = false;
|
||||
|
||||
Reference in New Issue
Block a user