简体   繁体   English

gridview Flutter 中 Listtile/卡的背景图像

[英]Background image for Listtile/card in gridview Flutter

I have a widget tree as Gridview>Container>Card>ListTile but instead of having a leading image on the ListTile I want this as the background image of the card, is there a way to achieve this look?我有一个作为 Gridview>Container>Card>ListTile 的小部件树,但是我希望将其作为卡片的背景图像,而不是在 ListTile 上有一个前导图像,有没有办法实现这种外观?

If i understand your question correctly, you can put that image in a Container:如果我正确理解您的问题,您可以将该图像放入容器中:

Card(
    child: Container(
      decoration: BoxDecoration(
        image: DecorationImage(
          fit: BoxFit.cover,  //I assumed you want to occupy the entire space of the card
          image: AssetImage(
            'the_path_of_the_image',
          ),
        ),
      ),
      child: ListTile(
        leading: Text(
          'Testing the ListTile',
           style: TextStyle(color: Colors.white),
        ),
        title: Text(
          'Testing again!',
          style: TextStyle(color: Colors.white),
        ),
     ),
   ),
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM