【问题标题】:How to show circularprogressindicator along with bottomsheet in flutter?如何在颤动中显示圆形进度指示器和底片?
【发布时间】:2020-08-10 03:39:26
【问题描述】:

我在我的代码中使用了底页,因此当 isLoading 为真时它没有显示我的循环进度指示器,但三元运算符的其他部分工作正常。有没有其他方法可以做到这一点。或者我在代码中做错了什么?

  (isLoading==true) ? Center(
    child: Container(
      height: 24,
      width: 24,
      child: CircularProgressIndicator(
        backgroundColor: CommonColors.primaryColor,
        strokeWidth: 1,
      ),
    ),
  )
      :
  Column(
    children: <Widget>[
      Expanded(
        child: ListView.separated(
          itemCount: clist.cartlist.length,
          itemBuilder: (BuildContext context, int index) {
            return _buildCartProduct(index);
          },
          separatorBuilder: (context, index) {
            return Divider(
              color: Colors.grey[300],
            );
          },
        ),
      ),
      SizedBox(
        height: 80,
      )
    ],
  ),
  bottomSheet: isLoading?Container():Container(
    height: 80.0,
    color: CommonColors.secondaryBackgroundColor,
    child: Column(crossAxisAlignment: CrossAxisAlignment.end,
      children: <Widget>[
        Container(margin: EdgeInsets.symmetric(horizontal: 16),child:
        Text('Total: \$${clist.getSubTotal()}',
          style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16),)),
        Expanded(
          child: FlatButton(onPressed: (){},
            color: CommonColors.primaryColor,
            child: Row(mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'PLACE',
                  style: TextStyle(
                    color: CommonColors.secondaryBackgroundColor,
                    fontSize: 20.0,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    ),
  ),

【问题讨论】:

    标签: flutter dart bottom-sheet progress-indicator


    【解决方案1】:

    在这部分中,如果加载,您将显示一个空容器

    bottomSheet: isLoading?Container():Container(
    
    

    所以把它改成你的 CircularProgressIndicator

    bottomSheet: isLoading ? CircularProgressIndicator():Container(
    

    【讨论】:

    • 但如果我这样做,将会显示两个进度指示器,但我只想显示一个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 2021-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 2018-10-19
    相关资源
    最近更新 更多