Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在颤振中显示snackbar无限持续时间?_Flutter_Dart_Snackbar - Fatal编程技术网

Flutter 如何在颤振中显示snackbar无限持续时间?

Flutter 如何在颤振中显示snackbar无限持续时间?,flutter,dart,snackbar,Flutter,Dart,Snackbar,我在android studio中创建了颤振项目,并试图显示snackbar无限持续时间。这是我的代码 final snackBar = SnackBar( content: Text('Cart:'+countProducts.toString()+" Products($countCost:sum)",style: TextStyle(color: Colors.black),), shape: RoundedRectangleBorder( bor

我在android studio中创建了颤振项目,并试图显示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);

还有另一个按钮将更改snackbar文本。但是我不想将其驳回。因此,如何在颤振中显示snackbar infinite duration

您可以使用snackbar上的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),
//获取问题int!=双重的 );

使用
持续时间(秒:两倍无限)

但不确定这是否是最好的

编辑 您可以尝试以下操作,而不是使用
double.infinity

Duration(days: 365)
参考文献