ListTile 的颜色溢出其父级 - Flutter
Color of ListTile overflows its parent - Flutter
问题:ListTile 的'color' 和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"),
),
),
);
});
}
}
根据您在评论中提供的信息,您的问题是您没有用脚手架包裹您的小部件,所以尝试只用脚手架包裹它,它会起作用。
项目中应该只有一个 material 应用程序。但你可以拥有任意数量的脚手架。
问题:ListTile 的'color' 和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"),
),
),
);
});
}
}
根据您在评论中提供的信息,您的问题是您没有用脚手架包裹您的小部件,所以尝试只用脚手架包裹它,它会起作用。
项目中应该只有一个 material 应用程序。但你可以拥有任意数量的脚手架。