首页 > 解决方案 > 在同一屏幕上加载许多 json,如何等待一个并继续?

问题描述

我有一个带有多个 json 请求的屏幕,但它是同时加载的,我想什么时候finish one start the another到最后。

new CustomScrollView(
          cacheExtent: height * 5,
            slivers: [
              new SliverList(
                  delegate: new SliverChildListDelegate(
                    [
                      new RelatorioVendPeriodoAPeriodo(),
                          new RelatorioDiasDaSemanas(),
                      new RelatorioVendasTotalidasPorPeriodo(),
                      new RelatorioDasVendasTotsProdutos(),
                      new RelatorioMensals(),

                    ]
                  )
              )
            ]
        ),

这个类加载一个json请求,如何划分并等待一个开始另一个?

这是此类返回方法之一:

  Widget build(BuildContext context) {
    double height =  (MediaQuery.of(context).size.height) - kRadialReactionRadius - kToolbarHeight;
    return new Container(
      height: height,
      padding: new EdgeInsets.only(left: 5.0, right: 5.0),
      child: new Card(
        elevation: 10.0,
        child:
        new Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              new Column(crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  new ListTile(
                    trailing:
                    _buildCounterButton(),
                    title: new Center(child: new Text('FATURAMENTO MENSAL', style: new TextStyle(fontWeight: FontWeight.bold))),
                    subtitle: new Icon(Icons.info),
                    onTap: _showDialog,
                  ),
                            new FutureBuilder<List<RelatorioMensal>>(
                            future: fetchRelatorioMensal(new http.Client(), "", '$dateFinal1Sem'),
                            builder: (context, snapshot) {
                              if (snapshot.hasError) print(snapshot.error);
                              return snapshot.hasData
                                  ? new porVendaMensal(listVendasMensais: snapshot.data,)
                                  : new Center(child: new CircularProgressIndicator());
                            }
                  ),
                ],),]
        ),
      ),

    );
  }

标签: jsondartflutterfuture

解决方案


推荐阅读