How to display snackbar infinite duration in flutter? How to display snackbar infinite duration in flutter? dart dart

How to display snackbar infinite duration in flutter?


You can use the Duration property on the snackbar

Example

final snackBar = SnackBar(    content: Text('Cart:'+countProducts.toString()+" Products($countCost:sum)",style: TextStyle(color: Colors.black),),      shape: RoundedRectangleBorder(          borderRadius: BorderRadius.only(topLeft:Radius.circular(22),topRight:Radius.circular(22))),    backgroundColor: Colors.white70,    action: SnackBarAction(      textColor: Colors.blueAccent,      label: "Buy",      onPressed: () {        // Some code to undo the change.      },    ),   duration: Duration(seconds: double.infinity),

//Gets problem int != double );

using Duration(seconds: double.infinity)

Not Sure if this is the best though.

EDIT

You can try the following instead of using double.infinity

Duration(days: 365)

Reference