我在代码中使用了底层表单,由于当isLoading为true时它没有显示我的circleprogressindicator,但是三元运算符的一部分运行正常。还有其他方法可以做到这一点。还是我在代码中做错了什么?
(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,
),
),
],
),
),
),
],
),
),
答案 0 :(得分:0)
在此部分,如果要加载,则显示一个空容器
bottomSheet: isLoading?Container():Container(
因此将其更改为您的CircularProgressIndicator
bottomSheet: isLoading ? CircularProgressIndicator():Container(