建筑布局颤振-列和容器

时间:2018-07-24 12:19:19

标签: layout containers flutter flutter-layout

上帝的日子,

在布局方面遇到麻烦时,有人可以帮忙吗?

编辑:

我会尽力解释。

我有这个屏幕:

Screen who i needs in the end

使用以下代码:

return new Container(
      height: height,
      padding: new EdgeInsets.all(10.0),
      child: new Card(
          elevation: 10.0,
          child:
          new Column(
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
                new ListTile(
                  trailing:
                  _buildCounterButton(),
                  title: new Center(child: new Text('VENDAS POR PRODUTOS', style: new TextStyle(fontWeight: FontWeight.bold))),
                  subtitle: new Center(child: new Padding(padding: new EdgeInsets.only(top: 5.0), child:
                  new Text('Top 3 produtos dos últimos 30 dias', textAlign: TextAlign.center,))),
                ),


                        new FutureBuilder<List<RelatorioProdutos>>(
                          future: fetchRelatorioPorProduto(new http.Client(),'$dateInicial', '$dateFinal'),
                          builder: (context, snapshot) {
                            if (snapshot.hasError) print(snapshot.error);
                            else
                              auxTelaDetalhada = RelatorioVendasTotalizadasProdutos(prods: snapshot.data, aondeVoltar: 0,);

                            return snapshot.hasData
                                ? new porProdutoList(listas: snapshot.data)
                                : new Center(child: new RefreshProgressIndicator());

                          },
                        ),

                new Expanded(
                    child: new Align(
                        alignment: Alignment.bottomCenter,
                        child: new Padding(padding: new EdgeInsets.only(bottom: 10.0),
                        child: new RaisedButton(
                            child: new Text("Relatório Completo",
                              style: new TextStyle(color: Colors.white, fontSize: 20.0),),
                            color: Colors.blue,
                            elevation: 8.0,
                            splashColor: Colors.lightBlue,
                            onPressed: () {
                              Navigator.pushReplacement(
                                context,
                                new MaterialPageRoute(
                                    builder: (context) => auxTelaDetalhada),
                              );
                            }
                        ),))),
            ],)        
      ),
    );

我想在流程结束时显示此屏幕。

但是我有这种方法:

new FutureBuilder<List<RelatorioProdutos>>(
                          future: fetchRelatorioPorProduto(new http.Client(),'$dateInicial', '$dateFinal'),
                          builder: (context, snapshot) {
                            if (snapshot.hasError) print(snapshot.error);
                            else
                              auxTelaDetalhada = RelatorioVendasTotalizadasProdutos(prods: snapshot.data, aondeVoltar: 0,);

                            return snapshot.hasData
                                ? new porProdutoList(listas: snapshot.data)
                                : new Center(child: new RefreshProgressIndicator());

                          },
                        ),

此方法会加载json请求,我需要按钮仅出现在json请求的结尾。

所以我想把这个RaisedButton放在另一个方法返回中,这个按钮只出现在json请求的末尾。但是,当我将其放在其他方法中时,我无法对齐此按钮。

其他方法:

Widget test =

        new Column(
        children: <Widget>[
            listaTiles[0],
            listaTiles[1],
            listaTiles[2]]);



      return test;

我正打算这样做:

 Widget test =

      new Column(children: <Widget>[
        new Column(
            children: <Widget>[
              listaTiles[0],
              listaTiles[1],
              listaTiles[2]]),
        new Align(
                alignment: Alignment.bottomCenter,
                child: new Padding(padding: new EdgeInsets.only(bottom: 10.0),
                  child: new RaisedButton(
                      child: new Text("Relatório Completo",
                        style: new TextStyle(color: Colors.white, fontSize: 20.0),),
                      color: Colors.blue,
                      elevation: 8.0,
                      splashColor: Colors.lightBlue,
                      onPressed: () {
                        Navigator.pushReplacement(
                          context,
                          new MaterialPageRoute(
                              builder: (context) => auxTelaDetalhada),
                        );
                      }
                  ),)),
      ],);

但是我明白了:

This, after change the methods

任何人都想让这个工作正常吗?

2 个答案:

答案 0 :(得分:0)

尝试一下... 在这里Flutter: Trying to bottom-center an item in a Column, but it keeps left-aligning

回答了这个问题
return new Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisSize: MainAxisSize.max,
      mainAxisAlignment: MainAxisAlignment.end,
      children: <Widget>[
          //your elements here
      ],
    );

答案 1 :(得分:0)

尽管我应该在评论中写下它,但它仍然需要 50个信誉,但是无论如何。

这将为您提供帮助,如果您想使其居中,则将列包装在中心小部件中

Center(
            child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: <Widget>[
                    Container(Text("Hello to all", style: TextStyle(fontSize: 60.0)))
                    ],
                  ),
          ),

这将产生以下结果。希望这是您正在寻找的:) enter image description here