I am an Android developer and I am trying to develop a very simple application in order to discover Flutter.
I would like to create a list with very simple cells. A card with:
- on the left an image with a fixed width. The height should match the parent container ;
- on the right some text fields that are stacked vertically.
I can align the widgets correctly but impossible for the image to set the height property as "match parent".
Here my current tree:
Widget _buildTabBarView({@required List<AttractionCategory> categories})
{
return TabBarView(
children: <Widget>[
for(var category in categories)
Container(
child: ListView.builder(
padding: EdgeInsets.all(8),
itemCount: category.attractions.length,
itemBuilder: (context, index)
{
return Card(
clipBehavior: Clip.antiAliasWithSaveLayer,
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 8),
child: Image(
fit: BoxFit.fill,
width: 125,
image: AssetImage(category.attractions[index].photo),
),
),
Expanded(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 8, top: 8, right: 8),
child: Align(
alignment: Alignment.topLeft,
child: Text(
category.attractions[index].name,
style: Theme.of(context).textTheme.title,
),
),
),
Padding(
padding: EdgeInsets.only(right: 8, bottom: 8),
child: Align(
alignment: Alignment.topLeft,
child: Text(
category.attractions[index].description,
style: Theme.of(context).textTheme.body1,
),
),
),
(category.attractions[index].size != null) ? Padding(
padding: EdgeInsets.only(right: 8, bottom: 8),
child: Align(
alignment: Alignment.topLeft,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 8),
child: Icon(
Icons.accessibility_new,
size: 16,
),
),
Text(
category.attractions[index].size,
style: Theme.of(context).textTheme.body1.copyWith(color: Color.fromARGB(255, 57, 180, 54)),
),
],
),
),
) : Container(),
],
),
),
],
),
);
},
),
),
],
);
}
And here the output:
As you can see, the Image's height does not match parent.
How can I achieve that ?
Do not hesitate to suggest me a whole new tree if mine is awful!
Thank you for your help!