Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add borders for SnackBar in Flutter?

Tags:

flutter

dart

I'm doing system messages, I decided to use SnackBar, but I ran into a problem - I can't add a border around the SnackBar, I need to make a colored border. Please tell me, is it possible to add a border to the SnackBar and how? Perhaps there are packages that allow you to do this?

like image 897
Max Avatar asked Sep 12 '25 07:09

Max


1 Answers

Try this

final snackBar = SnackBar(
      content: Text('test'),
      action: SnackBarAction(
        label: 'test label',
        textColor: Colors.white,
        onPressed: () {},
      ),
      behavior: SnackBarBehavior.floating,
      shape: RoundedRectangleBorder(
        side: BorderSide(color: Colors.red, width: 1),
        borderRadius: BorderRadius.circular(24),
      ),
      backgroundColor: Colors.blue,
)

Point is behavior, shape

like image 121
Taz Avatar answered Sep 13 '25 20:09

Taz