flutter - 即使使用 singleChildScrollView LIstview.bulder,底部也会溢出
问题描述
我正在尝试在颤振应用程序中实现列表。这是我的身体:
Container(
padding: EdgeInsets.fromLTRB(35.0, 40.0, 0.0, 0.0),
child: Column(
children: <Widget>[
Text(
date,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30.0,
color: Colors.teal,
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat'),
),
SingleChildScrollView(
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: people.length,
itemBuilder: (BuildContext context, int index){
return Card(
color: Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 4.0, horizontal: 6.0),
child: Center(
child: ListTile(
onTap: () => {},
title: Text(
"Name: "+people[index]['name'],
style: TextStyle(
color: Colors.teal,
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat',
fontSize: 21
),
),
subtitle: Text(
"Phone number: "+people[index]['phone'],
style: TextStyle(
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat',
fontSize: 16
),
),
)
)
),
);
},
),
)
],
)
),
如您所见,我将其用作身体的根小部件。该容器有一个子列,其中包含一个文本,该文本是页面的标题和一个SingleChildScrollView
有助于列表滚动的文本。我期待得到一个可以滚动的列表,但底部被溢出了。任何帮助,将不胜感激。谢谢你。
解决方案
将 Listview 包装在 Expanded 小部件中
Expanded(
child: ListView.builder()
)
或使用 Container 并设置高度和宽度
推荐阅读
- html - 无法在移动设备上滚动 HTML 页面
- c++ - 当所有等级都可以看到将要广播的数据时,使用 MPI_Bcast 有什么意义?
- c# - 如何在 Unity 中的特定位置生成预制件,然后删除该值?
- constants - (HLSL,DirectX9)为什么 GetConstantByName 返回一个空句柄?
- xml - 如何正确地将一些对象放入列中?
- azure - AKS TLS 使用应用服务证书/密钥保管库
- android - 日志 drom dart:developer 在 Flutter 应用的发布模式下是否可见?
- css - 发货说明 CSS 错误 woocommerce
- python - 字符串中的字符频率(Python 3.9)
- flutter - 如何将索引或 ID 传递给 Flutter 中的任何音频包