[英]Circular progress indicator without Future Builder flutter
How can I add circular progress indicator by the time I press the Elevated Button while I am waiting for my data to show?如何在等待数据显示时按下提升按钮时添加圆形进度指示器? It would be possible without the need of implementing Future Builder?
不需要实现 Future Builder 有可能吗?
ElevatedButton(
onPressed: (() async {
await postML(
_mySelectionFeat1,
_mySelectionFeat2,
_mySelectionFeat3,
_mySelectionValue1,
_mySelectionValue2,
_mySelectionValue3);
}),
child: Text('Post')),
ShowDogCard == false
? const Center(
child: Text('Please select features and values'),
)
: Container(
child: ListCard(
screen: 'ML',
doglist: BreedList,
index: idxBreedListPredicted,
),
),
A way is to have a boolean variable what you set true when you wanna start showing the CircularProgressIndicator, and then set false when you don't want to show it anymore:一种方法是设置一个布尔变量,当您想开始显示 CircularProgressIndicator 时设置为 true,然后在不想再显示时设置为 false:
bool _loading = true;
build() {
return _loading ? CircularProgressIndicator() : mainWidget();
}
But the best way is to use FutureBuilder.但最好的方法是使用 FutureBuilder。 That's what it is for.
这就是它的用途。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.