繁体   English   中英

没有 Future Builder 颤振的圆形进度指示器

[英]Circular progress indicator without Future Builder flutter

如何在等待数据显示时按下提升按钮时添加圆形进度指示器? 不需要实现 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,
            ),
          ),

一种方法是设置一个布尔变量,当您想开始显示 CircularProgressIndicator 时设置为 true,然后在不想再显示时设置为 false:

bool _loading = true;

build() {
  return _loading ? CircularProgressIndicator() : mainWidget();
}

但最好的方法是使用 FutureBuilder。 这就是它的用途。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM