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
未发现任何问题时显示错误)
答案 0 :(得分:2)
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(),
),
结果: