Skip to content

Commit

Permalink
Improve resizing of image widgets
Browse files Browse the repository at this point in the history
Two changes to improve resizing of ImageWidget:
- give users a better feedback with a gray background behind the image,
- fit the image using BoxFit.contain so that it doesn't stretch
  • Loading branch information
mauriziopinotti committed Aug 30, 2024
1 parent 4d72e4e commit 098f6b2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/src/objects/image_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ class _ImageWidgetState extends State<ImageWidget> {
return const Center(child: CircularProgressIndicator());
}

return Image(
image: widget.imageProvider,
width: widget.element.size.width,
height: widget.element.size.height,
return ColoredBox(
color: Colors.black12,
child: Image(
image: widget.imageProvider,
width: widget.element.size.width,
height: widget.element.size.height,
fit: BoxFit.contain,
),
);
}
}

0 comments on commit 098f6b2

Please sign in to comment.