Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 702 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image Scale type center crop on flutter?

#1
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]:

Reply

#2
new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Expanded(child: new Image.network(
cover.img,fit: BoxFit.fitWidth,
),

),
Text(cover.name),
]
)
this works for me
Reply

#3
new Center(
child: Container(
child: new Stack(
children: <Widget>[
new Image.asset(
'assets/images/firebase1.png',
width: 100.0,
height: 100.0,
),
],
),
),
),
Reply

#4
Please add this following width and height to the image

Note: We are zooming the image

height: double.infinity,
width: double.infinity,`
Reply

#5
Android ScaleType and BoxFit should match like this:

1. CENTER = none
2. CENTER_CROP = cover
3. CENTER_INSIDE = scaleDown
4. FIT_CENTER = contain (alignment.center)
5. FIT_END = contain (alignment.bottomright)
6. FIT_START = contain (alignment.topleft)
7. FIT_XY = fill

> **Ex :-** `Image.asset('assets/images/your_image.png',fit: BoxFit.fill)`

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.
Reply

#6
If you want to fill the parent widget with an image you should use (as already pointed out by [Antonino][1]) `BoxFit.cover` together with a width and height of `infinity` to consume the space of the parent view.

```dart
Image.network(
imageUrl,
fit: BoxFit.cover,
width: double.infinity,
height: double.infinity,
),
```


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through