ListTile 的颜色溢出其父级 - Flutter

时间:2021-06-29 01:46:08

标签: flutter flutter-layout flutter-listview

问题:ListTile 和 HoverColor 的“颜色”溢出了它们的父级。也许还有其他颜色,但我还没有测试过。 这是这个奇怪问题的截图。 screenshot

@override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: titles.length,
        itemBuilder: (context, index) {
          return GestureDetector(
            onSecondaryTap: () {
              print('clicked index : $index');
            },
            child: ListTile(
              hoverColor: Colors.amber,
              title: Padding(
                padding: EdgeInsets.only(bottom: 0, top: 0),
                child: Text(
                  titles[index],
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                    color: dark,
                    fontSize: 14,
                  ),
                ),
              ),
              subtitle: Padding(
                padding:
                    const EdgeInsets.only(bottom: 0, top: 0, left: 0, right: 0),
                child: Text(
                  subtitles[index],
                  style: TextStyle(
                    color: _statusColor(subtitles[index]),
                    fontSize: 11,
                  ),
                ),
              ),
              leading: CircleAvatar(
                radius: 25,
                backgroundImage: NetworkImage(
                    "https://images.unsplash.com/photo-1547721064-da6cfb341d50"),
              ),
            ),
          );
        });
  }
}

1 个答案:

答案 0 :(得分:0)

根据你在评论中提供的信息,你的问题是你没有用脚手架包裹你的小部件,所以试着用脚手架包裹它,它会起作用。

项目中应该只有一个材质应用。但您可以拥有任意数量的脚手架。