I am using Flutter to develop an app and I have a row in a card with three items, I am try to fill the area for the last item with a color but there seems to be padding arou
The trick is to set on your Row
crossAxisAlignment
to CrossAxisAlignment.stretch
.
This will force all it's children to expand vertically.
But then you have to add an height constraint or else the row will expand on the vertical axis.
The easiest solution in your case is to wrap your Row
into a SizedBox
with a fixed height and unconstrained width. Where the height would be equal to ListTile
height, as it's the biggest element of your list. So 56.0, considering you have a one line title and without dense
property.
Then you may want to align your Text
inside the colored container. As it's top aligned instead of vertical centered.
Which can be achieved with the alignment
property on Container
set to Alignment.center
or Alignment.centerLeft/Right
depending on your need.
new Container(
margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
child: new InkWell(
child: new Card(
child: new SizedBox(
height: 56.0,
child: new Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Expanded(
child: new ListTile(
title: new Text('foo'),
),
),
new Container(
color: Colors.blue,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: new Text(
"foo",
style: new TextStyle(color: Colors.white),
),
),
],
),
),
),
),
)