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(),
),
结果:关于android - flutter :ListWheelScrollView放大镜不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63545893/