在同一屏幕上加载许多json,如何等待一个并继续?

时间:2018-08-03 11:16:44

标签: json dart flutter future

我的屏幕上有多个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());
                            }
                  ),
                ],),]
        ),
      ),

    );
  }

0 个答案:

没有答案