fix: handle mpv end-file errors with global snackbar
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user