07-21-2023, 08:33 PM
I'm trying to do something similar to centerCrop property from android ImageView.
Setting the height of the imageview, and making it crop and align to center, just as centerCrop works on android.
Widget bindItem(BuildContext context, int index) {
return new Card(
child: new Column(
children: <Widget>[
new Image.network(
_parties[index]["cover"], fit: BoxFit.fitWidth,
height: 120.0,
),
new Text(_parties[index]['name'])
]
)
);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Parties"),
),
body: new ListView.builder(
itemCount: _parties == null ? 0 : _parties.length,
itemBuilder: bindItem,
)
);
}
Result:
[![enter image description here][1]][1]
[1]:
Setting the height of the imageview, and making it crop and align to center, just as centerCrop works on android.
Widget bindItem(BuildContext context, int index) {
return new Card(
child: new Column(
children: <Widget>[
new Image.network(
_parties[index]["cover"], fit: BoxFit.fitWidth,
height: 120.0,
),
new Text(_parties[index]['name'])
]
)
);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Parties"),
),
body: new ListView.builder(
itemCount: _parties == null ? 0 : _parties.length,
itemBuilder: bindItem,
)
);
}
Result:
[![enter image description here][1]][1]
[1]: