import 'package:flutter/material.dart'; class UIFeedbackService { final GlobalKey _scaffoldKey; UIFeedbackService(this._scaffoldKey); void showSuccess(String message) { showMessage(message, Colors.green); } void showError(String message) { showMessage(message, Colors.red); } void showWarning(String message) { showMessage(message, Colors.orange); } void showMessage(String message, [Color? color]) { _scaffoldKey.currentState?.showSnackBar( SnackBar( content: Text(message), backgroundColor: color, duration: const Duration(seconds: 2), ), ); } void showMessageWithAction({ required String message, required String actionLabel, required VoidCallback onActionPressed, Color? backgroundColor, }) { _scaffoldKey.currentState?.showSnackBar( SnackBar( content: Text(message), backgroundColor: backgroundColor, action: SnackBarAction( label: actionLabel, onPressed: () => onActionPressed(), ), duration: const Duration(seconds: 4), ), ); } }