Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asset image as a Card background with text on top in Flutter

I'm using a Card widget in flutter to display text. I want to use an asset image as the background/texture for the card, and display text on top. I'm having trouble figuring out how to layer the widgets properly. Any insight is much appreciated.

like image 849
Alex East Avatar asked Jan 29 '19 01:01

Alex East


1 Answers

Do something like this:

    Card(
      child: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("images/image.png"),
            fit: BoxFit.fitWidth,
            alignment: Alignment.topCenter,
          ),
        ),
        child: Text("YOUR TEXT"),
      ),
    ),
like image 199
Harsh Bhikadia Avatar answered Sep 17 '22 17:09

Harsh Bhikadia