-
Notifications
You must be signed in to change notification settings - Fork 580
Open
Description
I'm trying to render a zoomable/panable Stack - that is a large photo with positioned informations on top of it.
Here is an example:
Stack(
fit: StackFit.expand,
clipBehavior: Clip.none,
children: [
const Image(
image: AssetImage(
'assets/images/some-photo.jpg'), // This may be large (eg. height 5000 x width 3000)
),
Positioned( // The values are based on the photo dimension, in order to inform a specific area
top: 2500,
left: 1500,
child: Container(
color: Colors.red.withOpacity(0.5),
width: 380,
height: 380,
),
),
],
),Thing is Stack resizes the children to fit its container:
- the image is resized to container height
- the Positioned is placed according to the container's dimension, that is likely off screen considering the offset values.
In any case, positioned locations is desynchronized with the image underneath.
One solution I found was to make the Stack grow as much as needed. This way I ensure the underneath image is not shrinked, and the positionned elements remain correct:
OverflowBox(
maxWidth: 3000, // Image width
maxHeight: 5000, // Image height
child: Stack(
// Stack content here
),
),Although content of the Stack is now correct, if I put this in PhotoView, the PhotoViewComputedScale is not correct:
PhotoView.customChild(
initialScale: PhotoViewComputedScale.contained, // Whole image expected, but it's zoomed in
minScale: PhotoViewComputedScale.contained * 0.8,
basePosition: Alignment.center,
child: // Overflowbox here
),Indeed, the Overflowbox dimension seems not to be taken into account. I tried to wrapped it in a SizedBox at image's dimension with no success.
Would you know how to solve this?
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels