android - 颤振:ListWheelScrollView 放大镜不起作用
问题描述
ListWheelScrollView 的放大镜是空的(只是一个白色的容器)
ListWheelScrollView(
itemExtent: 60,
magnification: 2,
useMagnifier: true,
children: List.generate(
100,
(index) => Card(
key: ValueKey(index),
color: Colors.blue,
child: ListTile(
title: Text(index.toString()),
))).toList(),
),
我究竟做错了什么?(运行时不显示错误flutter run -v
并且flutter doctor -v
没有发现问题)
解决方案
- 您可以使用
Container
代替Card
并为其设置水平padding
:
ListWheelScrollView(
itemExtent: 60,
magnification: 1.5,
useMagnifier: true,
squeeze: 0.7,
children: List.generate(
100,
(index) => Container(
key: ValueKey(index),
padding: EdgeInsets.symmetric(horizontal: 100),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(8),
),
child: ListTile(
title: Text(index.toString()),
),
)).toList(),
),
结果:
- 您可以将文本放在直接放置在内部的小部件中,而不是使用
ListTile
和水平:padding
Center
Container
ListWheelScrollView(
itemExtent: 60,
magnification: 1.5,
useMagnifier: true,
squeeze: 0.7,
children: List.generate(
100,
(index) => Container(
key: ValueKey(index),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text(index.toString()),
),
)).toList(),
),
结果:
推荐阅读
- php - php解析url并删除参数问题
- format - 仅将 ESLint / Prettier 应用于选定的行
- angularjs - 我可以与 Angular 的 Redshfit 联系以进行报告吗?
- excel - VBA使用ColumnBound在组合框中选择值
- reactjs - React 状态变量的特殊操作
- python - 如何在 Python 中使用不同的格式条件退出 while True 循环?
- python - 如何将 DirectInput 键发送到 Python 中的非活动窗口
- r - 删除一组子文本之前的文本
- java - 使用 Jackson 读取最外层的 JSON 对象而不是内部的对象?
- c++ - 如何使用 std::shared_ptr 的多重继承?