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:
Android ScaleType and BoxFit should match like this:
So you should use Cover to achieve the CENTER_CROP result.
EDIT:
The problem should be crossAxisAlignment of the Column widget. Setting this property to crossAxisAlignment: CrossAxisAlignment.stretch should fix your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With