Öme*_*lan 5 dart flutter flutter-layout
我在 AlertDialog 容器中有一个 ListView 。有一种 InkWell 方法,但波纹效果不起作用,而且我无法放置分隔符。如何放置分隔符并产生涟漪效应?
Widget setupAlertDialoadContainer(context) {
return Container(
color: Colors.white,
height: 300.0,
width: 300.0,
child: ListView.builder(
itemCount: showroomModel.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () => {
print(showroomModel[index]),
},
child: ListTile(
title: Text(showroomModel[index]),
),
);
}),
);
Run Code Online (Sandbox Code Playgroud)
}
对于InkWell
连锁反应,请尝试将其包装InkWell
在Material
小部件中。
Material(
child: InkWell(
onTap: () {
print(showroomModel[index]);
},
child: ListTile(
title: Text(showroomModel[index]),
),
),
)
Run Code Online (Sandbox Code Playgroud)
对于分隔符,请使用ListView.separated
Tasnuva oshin 的答案。
正如 TheFabbius 所指出的,上面的代码也可以通过删除InkWell
并onTap
移动ListTile
.
Material(
child: ListTile(
onTap: () {
print(showroomModel[index]);
},
title: Text(showroomModel[index]),
),
)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1168 次 |
最近记录: |