How to make flutter card auto adjust its height depend on content

前端 未结 3 754
名媛妹妹
名媛妹妹 2021-02-14 17:41

In the project im using image and text inside the flutter card, but the card return a fixed height. and then i also tried just using a card with an empty value, but it still ret

3条回答
  •  滥情空心
    2021-02-14 18:02

    You want to wrap your card in a Column because the inner Column take full height

     Column(children: [
          Card(
            margin: const EdgeInsets.all(10.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                AspectRatio(
                  aspectRatio: 18.0 / 13.0,
                  child: Image.network(
                   "https://picsum.photos/200",
                    fit: BoxFit.fill,
                  ),
                ),
                Padding(
                  padding: EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        "Just add your desired image size (width & height) after our URL, and you'll get a random image.",
                        textAlign: TextAlign.center,
                      ),
                    ],
                  ),
                ),
              ],
            ),
          )
    ])
    

提交回复
热议问题