I'm trying to learn to use better layouts with Card
which I've seen one that I like but it seems to have a type Container
placed at the bottom of the Card
with a different color, which gives it another layout
What I want
What I have
I tried using a Positioned
but it doesn't move or anything, I still tried putting the Positioned
inside a Stack
but in that case I simply lost the Container
.
What I have.
ListView.builder
where the los is shown Card
with the help of aWrap
ListView.builder(
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Wrap(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
alignment: WrapAlignment.center,
spacing: 10.0,
runSpacing: 10.0,
children: List<Widget>.generate(10, (index) => _card('produto $index',0.0,'$index descripción')),
);
},
),
Widget _card(String title, double precio, String descripcion) {
return Container(
// margin: EdgeInsets.all(4.0),
width: 150,
height: 180,
child: Card(
color: Color(0xff00bc9b),
child: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text(
'Producto 1',
style: TextStyle(color: Color(0xffEDFAF8), fontWeight: FontWeight.bold),
textAlign: TextAlign.start,
),
ClipRRect(
borderRadius: BorderRadius.circular(5.0),
child: Image.asset(
'assets/img/no-image.png',
height: 70,
fit: BoxFit.fill,
)),
Positioned(
bottom: 10.0,
child: Container(
// height: 55,
decoration: BoxDecoration(
color: Colors.blue/* Color(0xffEDFAF8) */,
borderRadius: BorderRadius.only(topRight: Radius.circular(10))),
child: Row(
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Producto de alta calidad para el consumo de todos, o solo texto largo',
overflow: TextOverflow.ellipsis,
// style: TextStyle(color: Colors.white),
),
Text(
'\$4.50',
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
color: Colors.black,
child: IconButton(
icon: Icon(
Icons.add,
color: Colors.white,
),
onPressed: () {}),
),
),
],
),
),
)
],
),
),
);
}
What you lacked for the content to be contracted was only
mainAxisSize: MainAxisSize.min
in theColumn
and well aRow
.I prepared an example so you can imitate the image you put, here it is:
Result