flutter - 我希望我的身体在 Flutter 中可以滚动
问题描述
我是新来的,我正在尝试滚动我的整个脚手架。我有一个 StreamBuilder、ListView.builder 和很多东西。
这是我的身体:
body: Column(
children: [
StreamBuilder<QuerySnapshot>(
stream:_someStreamingFunction(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Card(
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: []
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'Loading',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18.0,
),
),
SpinKitThreeBounce(
color: Colors.black,
size: 12.0,
),
],
),
Expanded(
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount:
transactions.length != 0 ? transactions.length : 0,
itemBuilder: (context, index) {
return CustomTile(.....);
},
),
)
],
),
);
}
});
],
),
我尝试了多种方法来做到这一点,没有任何效果。
我已经清除了一些代码,以便更好地理解。
更新我也尝试将我的身体包裹在 SingleChildScrollView
body: SingleChildScrollView(
child: Column(
children: [
],
),
),
这是错误:
======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
When a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent.
解决方案
使用 SingleChildScrollView小部件并删除扩展的小部件。像这样你的整个页面将是可滚动的。
推荐阅读
- jmeter - Jmeter - 分布式(远程)测试执行从连接在执行过程中关闭
- javascript - 使用 router.get('/me', (res,req) => {}) 时如何访问身份验证信息
- javascript - 如何使用 javascript 减少实时日期/时间字符串?
- python - 使用 Python 从网页抓取到动态表
- javascript - 在这种情况下如何优化我的变量?
- arrays - 我可以在继承的对象上覆盖 'ComVisible(false) 吗?(vb)
- python - 'tk.wm_attributes("-topmost", 1) 中的那个是什么意思?
- flutter-bloc - 冻结 - 一组密封类,其中一些具有其他人没有的字段 - 导致 bloc.state 无法访问缺少的字段
- java - 错误:org.json.JSONArray 无法转换为 JSONObject
- assembly - 理解 ARM 向量表汇编声明的语法