Flutter列表视图波纹效果不起作用

Ö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)

}

mmc*_*n20 7

对于InkWell连锁反应,请尝试将其包装InkWellMaterial小部件中。

Material(
  child: InkWell(
    onTap: () {
      print(showroomModel[index]);
    },
    child: ListTile(
      title: Text(showroomModel[index]),
    ),
  ),
)
Run Code Online (Sandbox Code Playgroud)

对于分隔符,请使用ListView.separatedTasnuva oshin 的答案。


正如 TheFabbius 所指出的,上面的代码也可以通过删除InkWellonTap移动ListTile.

Material(
  child: ListTile(
    onTap: () {
      print(showroomModel[index]);
    },
    title: Text(showroomModel[index]),
  ),
)
Run Code Online (Sandbox Code Playgroud)