flutter - Flutter:Container + ListView 可滚动
问题描述
我有一个带有容器 + listView 的页面。现在 listView 是可滚动的,但我希望整个页面都是可滚动的。(所以如果用户滚动,容器就会“离开”)
Column(
children: <Widget>[
Container(
color: Colors.white.withOpacity(0.95),
width: 400,
height: 400,
child: Text("")),
ListView(
children: posts,
),
],
),
这可能吗,如何实现?
谢谢!
解决方案
你可以用一个包裹整个页面SingleChildScrollView
这是一个例子:
SingleChildScrollView( // <- added
child: Column(
children: <Widget>[
Container(
color: Colors.white.withOpacity(0.95),
width: 400,
height: 400,
child: Text("")),
ListView(
shrinkWrap: true, // <- added
primary: false, // <- added
children: posts,
),
],
),
);
有关查看此问题的更多信息
推荐阅读
- python - 冒号在 pycharm 中不存在
- ios - URLSession.shared.dataTaskPublisher - 如何将接收到的值转换为字符串?
- linux - Linux shell脚本知道目录(或文件)是否有777权限
- java - 通知未在所选时间显示
- gradle - 从 gradle 任务中删除现有输入
- python - 试图找到最长的子字符串而不重复字符
- visual-studio-code - 自动右括号在 VS Code 中停止工作
- javascript - Bootstrap Popover 无法在 Mapbox Popup 中打开
- deep-learning - Detectron2 Mask R-CNN 细胞分割 - 什么都看不见
- haskell - 使用数据构造函数作为函数参数