flutter - 如何对齐 ListView 中的底部容器?

标签 flutter listview vertical-alignment

我想在 ListView 的底部中心添加一个按钮。

Scaffold(
  backgroundColor: Colors.white,
  appBar: buildAppBar(context, ''),
  body: ListView(
    physics: ClampingScrollPhysics(),
    children: [
      Column(
        children: [
          Text(
            'check up',
            style: TextStyle(
              fontSize: 35,
              fontWeight: FontWeight.bold,
              color: Colors.black,
            ),
          ),
          SizedBox(height: 12),
          Text(
            'SachsenwaldStr. 3. 12157 Berlin',
            style: TextStyle(
              fontSize: 20,
              color: Colors.black,
            ),
          ),
        ],
      ),
      Spacer(),
      buildNextButton(context),
    ],
  ),

我尝试使用Align,但它不起作用,Spacer() 也不起作用:

  Align(
        alignment: Alignment.bottomCenter,
        child: buildNextButton(context),
      ),

有什么方法可以将 buildNextButton 与底部对齐吗?

最佳答案

 return Scaffold(
    body: Stack(
  children: [
    Positioned(
      bottom: 0,
      width: MediaQuery.of(context).size.width,
      child: Center(
        child: MaterialButton(
          child: Text("My button"),
          onPressed: () {},
          color: Colors.red,
        ),
      ),
    ),
    ListView(
      children: [
        Text(
          'check up',
          style: TextStyle(
            fontSize: 35,
            fontWeight: FontWeight.bold,
            color: Colors.black,
          ),
        ),
        SizedBox(height: 12),
        Text(
          'SachsenwaldStr. 3. 12157 Berlin',
          style: TextStyle(
            fontSize: 20,
            color: Colors.black,
          ),
        ),
      ],
    )
  ],
));

OutPut

关于flutter - 如何对齐 ListView 中的底部容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70588514/

相关文章:

flutter :未处理的异常:无法加载 Assets : Assets /语言/en

firebase - flutter 查询

flutter - 使用预加载页面浏览播放 15 到 20 个视频后,我在 flutter 中遇到内存不足错误

flutter - 使用 Flutter 中的图像选择器插件选取视频的最大持续时间

html - 文本的垂直对齐方式和另一个内部的 div

javascript - 使 TouchableOpacity 在开始滚动时不突出显示元素 [React Native]

Android QuickContactBadge 带有类似 Android Lollipop 的字母

android - 从android中ListView的顶部和底部删除阴影?

html - 将 `<img>` 置于 `<div>` 的中心

html - 如何让我的 <p> 元素沿着 &lt;input&gt; 和 &lt;textarea&gt; 字段垂直居中?