在抽屉中,在列表视图中想要在单击 onTap 时更改 CustomListTile 的颜色并将所有其他子项的颜色设置为默认值?
class CustomListTile extends StatelessWidget {
final Color itemContainerColor;
const CustomListTile({
//deafult color is Colors.white
this.itemContainerColor= Colors.white,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: (){},
child: Container(
margin: EdgeInsets.symmetric(vertical: 4),
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 16),
width: 150,
decoration: BoxDecoration(
color: itemContainerColor,
)
child:
Text(
"ListTile 1",
style: TextStyle(
fontSize: 20,
color: Colors.green,
fontWeight: FontWeight.w600),
),
),
));
}
}