fix: handle mpv end-file errors with global snackbar

This commit is contained in:
edde746
2026-03-11 09:29:16 +01:00
parent 580c1d82e5
commit 3c491be690
7 changed files with 68 additions and 13 deletions
+10
View File
@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
/// Global key for the root ScaffoldMessenger, allowing snackbars to survive navigation.
final rootScaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
/// Types of snackbars available in the app
enum SnackBarType {
/// Standard informational snackbar
@@ -51,6 +54,13 @@ void showErrorSnackBar(BuildContext context, String message) {
showSnackBar(context, message, type: SnackBarType.error);
}
/// Shows an error snackbar using the root ScaffoldMessenger (survives navigation).
void showGlobalErrorSnackBar(String message) {
rootScaffoldMessengerKey.currentState?.showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.red, duration: const Duration(seconds: 4)),
);
}
/// Shows a success snackbar with a message
///
/// [context] The build context