showSnackBarWithAction function

void showSnackBarWithAction({
  1. required String message,
  2. required SnackBarAction action,
  3. required BuildContext context,
})

Implementation

void showSnackBarWithAction({
  required String message,
  required SnackBarAction action,
  required BuildContext context,
}) {
  final snackBar = SnackBar(
    behavior: SnackBarBehavior.floating,
    content: Container(
      margin: const EdgeInsets.all(5),
      child: Text(
        message,
        style: const TextStyle(color: Colors.white),
      ),
    ),
    backgroundColor: Colors.red,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(10),
    ),
    action: action,
  );
  ScaffoldMessenger.of(context).showSnackBar(snackBar);
}