I'm using flutter and I'm trying to create a kind of post card similar to a tweet.
I want to make a card when the text has different numbers of lines or an image is inside the container.
How do I make the container change size depending on what is inside?
Stack(
alignment: Alignment.center,
children: [
Container(
width: width,
decoration: const BoxDecoration(
border: Border(
bottom:
BorderSide(width: 0.5, color: Color(0xFFF525151)))),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(
left: 5, top: 5, right: 5, bottom: 2),
child: Container(
width: width,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(children: [
CircleAvatar(
radius: 25.0,
backgroundImage: AssetImage(
pictureprofil,
),
)
]),
Padding(
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(username,
style: TextStyle(
fontSize: 15.5,
fontFamily: 'DBIcons',
color: Colors.white,
fontWeight: FontWeight.bold)),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
pseudo,
style: TextStyle(
fontSize: 15.5,
fontFamily: 'DBIcons',
color: Colors.orange),
),
],
)
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
5,
0,
0,
0,
),
child: Text(
'2h',
style: TextStyle(
color: Colors.white,
fontSize: 15.5,
fontFamily: 'DBIcons',
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(80, 0, 0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
GestureDetector(
onTap: () => _likedChange(),
child: Icon(
liked
? Icons.favorite_border_outlined
: Icons.favorite,
color: liked ? Colors.white : Colors.red,
size: 19,
)),
Padding(
padding: const EdgeInsets.only(left: 4),
child: Text(
countlike,
style: TextStyle(
color: Colors.white,
fontSize: 15.5,
fontFamily: 'DBIcons',
),
),
),
GestureDetector(
onTap: () => _dislikedChange(),
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: Icon(
Icons.bolt,
color:
disliked ? Colors.white : Colors.red,
size: 18.2,
),
),
),
Text(countdislike,
style: TextStyle(
color: Colors.white,
fontSize: 15.5,
fontFamily: 'DBIcons',
)),
],
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 0, left: 55.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: width / 1.2,
height: height / 6,
/*decoration: BoxDecoration(
border: Border.all(color: null, width: 0.5)),*/
child: Text(
textbulle,
style: TextStyle(
height: 1.15,
color: Colors.white,
fontFamily: 'DBIcons',
fontSize: 15.5,
),
),
),
]),
),
Padding(
padding: const EdgeInsets.fromLTRB(55, 8, 5, 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommentsPopPage()));
},
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommentsPopPage()));
},
child: Icon(
Icons.chat_bubble_outline,
color: Colors.white,
size: 20,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 5.0),
child: Text(
countcomment,
style: TextStyle(
color: Colors.white,
fontSize: 15.5,
fontFamily: 'DBIcons',
),
),
),
Padding(
padding: const EdgeInsets.only(left: 22.0),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EkoPopPage()));
},
child: Icon(
Icons.adjust,
color: Colors.white,
size: 20,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 5),
child: Text(
counteko,
style: TextStyle(
color: Colors.white,
fontSize: 15.5,
fontFamily: 'DBIcons',
),
),
),
Padding(
padding: const EdgeInsets.only(left: 22),
child: Icon(
Icons.layers_outlined,
color: Colors.white,
size: 20,
),
),
Padding(
padding: const EdgeInsets.only(left: 5),
child: Text(
countcalque,
style: TextStyle(
color: Colors.white,
fontSize: 15.5,
fontFamily: 'DBIcons',
),
),
),
Padding(
padding: const EdgeInsets.only(left: 22),
child: Icon(
Icons.share,
color: Colors.white,
size: 16.5,
),
),
Padding(
padding: const EdgeInsets.only(left: 30.0),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
BulleTendance()));
},
child: Text(
themebulle,
style: TextStyle(
color: Colors.orange,
fontSize: 15.5,
fontFamily: 'DBIcons',
),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: InkWell(
onTap: () {
showModalBottomSheet(
context: context,
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: new Icon(Icons.block),
title: new Text('Bloquer'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.flag),
title: new Text('Signaler'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.insert_chart),
title: new Text('Statistiques'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.delete),
title: new Text('Supprimer'),
onTap: () {
Navigator.pop(context);
},
),
],
);
});
},
child: Container(
child: Icon(
Icons.more_vert_outlined,
color: Colors.white,
size: 16.5,
),
),
),
),
],
),
)
],
),
),
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
showLikeOverLay
? Icon(
Icons.favorite,
color: Colors.white,
size: 80,
)
: Container(),
showDislikeOverLay
? Icon(
Icons.bolt,
color: Colors.white,
size: 80,
)
: Container()
])
],
),