I have something like this:
InteractiveViewer(
boundaryMargin: const EdgeInsets.all(20),
minScale: 0.5,
maxScale: 3.0,
child: SingleChildScrollView(
child: Column(
children: [
Container(
color: Colors.red,
height: 100,
width: 100,
),
Row(
children: [
Container(
color: Colors.pink,
width: 200,
height: 100,
),
Container(
color: Colors.black,
width: 200,
height: 100,
),
Container(
color: Colors.pink,
width: 200,
height: 100,
),
Container(
color: Colors.black,
width: 200,
height: 100,
),
],
),
Container(
color: Colors.green,
width: 1000,
height: 100,
),
Container(
color: Colors.blue,
width: 200,
height: 200,
),
],
),
),
);
I never used this widget before and I’m trying to replicate a native behaviour so I could easily zoom in/out and scroll up/down. Like inspecting a photo on the phone.
Without any SingleChildScrollView
I see the "overflowed" error. Not sure if that’s really necessary. Right now I can only scroll up/down but I can’t zoom out to see the whole thing
2
Answers
I was just missing
constrained: false
To replicate the native behavior of inspecting a photo on the phone, where you can zoom in and out and scroll in all directions, you can use the InteractiveViewer without the SingleChildScrollView. The InteractiveViewer itself supports panning and zooming.
In my opinion, you can do this like this:
}
You should be able to zoom in and out and scroll in all directions to view the entire content. The InteractiveViewer will handle the scaling and panning of its child widgets.