KOr*_*rra 4 dart snackbar flutter
我在android studio中创建了flutter项目并试图显示snackbar无限持续时间。这是我的代码
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.
},
),
);
Scaffold.of(context).showSnackBar(snackBar);
Run Code Online (Sandbox Code Playgroud)
还有另一个按钮可以更改快餐栏文本。但我不想将它驳回。那么如何在颤动中显示小吃店的无限持续时间
Tin*_*son 10
您可以使用小吃店上的 Duration 属性
例子
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),
Run Code Online (Sandbox Code Playgroud)
//得到问题 int != double );
使用 Duration(seconds: double.infinity)
不确定这是否是最好的。
您可以尝试以下而不是使用 double.infinity
Duration(days: 365)
Run Code Online (Sandbox Code Playgroud)
参考
归档时间: |
|
查看次数: |
4837 次 |
最近记录: |