【问题标题】:How to add a container on the bottom page in FlutterFlutter中如何在底部页面添加容器
【发布时间】:2022-08-03 17:08:44
【问题描述】:

我想在屏幕底部添加带有“总金额”的容器。 我尝试使用 Alignment.bottom 中心,但没有。 现在,listview.builder 更小,容器就在下方。 我不想添加填充,因为我想要一些响应不同屏幕尺寸的东西。

这是我的代码:

    @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(...
      ),
      body:  Padding(
        padding: const EdgeInsets.only(top: 15.0),
        child: SingleChildScrollView(
          child: Container(
            height: MediaQuery
                .of(context)
                .size
                .height * 0.9,
            child: Column(
              children: <Widget>[
                ListView.builder(
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  itemBuilder: (contetx ,index) {
                  return Column(
                    children:[
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0, left: 15, right: 15),
                      child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(child: Text(widget.newList[index].name,
                          style: TextStyle(fontWeight: FontWeight.bold),),
                          margin: EdgeInsets.only(left: 5.0),),
                        Container(child: Text((widget.newList[index].quantity),
                          style: TextStyle(fontSize: 18),)),
                      ],
                      ),
                    ),
                      Divider(thickness: 1,indent: 20,endIndent: 20,),
                    ],
                  );
                },
                  itemCount: widget.newList.length,
                ),
                Align(
                  alignment: Alignment.bottomCenter,
                  child: Padding(
                    padding: const EdgeInsets.all(15.0),
                    child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(\'Total\'.toUpperCase().tr(),
                          style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),),
                        Text( (widget.totalRecipe),
                          style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),),
                      ],
                    ),

    标签: flutter user-interface listview


    【解决方案1】:

    只需在Align 之前使用Spacer

    【讨论】:

      猜你喜欢
      • 2020-05-02
      • 1970-01-01
      • 2015-05-11
      • 2022-11-25
      • 2013-09-12
      • 2021-11-11
      • 2013-11-18
      • 1970-01-01
      • 2022-08-07
      相关资源
      最近更新 更多