I want two images stack over each other in a gridview and both showing a
But when i add the stackwidget, the Image behaves like there is no
fit: BoxFit.cover
in its build method.
@override
Widget build(BuildContext context) {
if (widgetsList.length != 0) {
return new GridView.count(
primary: false,
crossAxisCount: 2,
children: widgetsList,
);
} else {
return Container();
}
}
@override
Widget build(BuildContext context) {
return new Stack(
children: <Widget>[
new CustomImage(compareTime: lastUpdatedPictureTime),
new CustomImage(compareTime: lastUpdatedIconTime)
],
);
}
@override
Widget build(BuildContext context) {
var img = imageBytes != null
? Image.memory(
imageBytes,
fit: BoxFit.cover,
)
: Text(errorMsg != null ? errorMsg : "Loading...");
return new Container(child: img);
}
When i use no stack and only use one CustomImage per Gridtile it works. So maybe this is a bug?
Try to add this line inside your Stack widget:
@override
Widget build(BuildContext context) {
return new Stack(
fit: StackFit.expand,
children: <Widget>[
new CustomImage(compareTime: lastUpdatedPictureTime),
new CustomImage(compareTime: lastUpdatedIconTime)
],
);
}
This worked for me :)
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