0

我想向我的 api 网络调用显示一个确定的进度指示器。

我见过其他解决方案,他们将时间硬编码为 2 秒。但是,我需要在拨打电话时启动进度指示器,并在我们得到响应时以 100% 完成。如您所知,时间可能会有所不同。

  @override
  void initState() {
    super.initState();
    bloc.fetchAllBusiness();
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
        stream: bloc.allBusinesses,
        builder: (context, AsyncSnapshot<List<BusinessModel>> snapshot) 
        {
          if (snapshot.hasData) {
            return buildList(snapshot);
          } else if (snapshot.hasError) {
            //error handling
          }
          //This is where i need show a determinate indicator
          return Center(child: LinearProgressIndicator(value:"???"));
        }

我需要知道,如何在此处设置双倍,"???"这会增加超时并达到1.0网络调用得到响应的时间。

4

0 回答 0