Zoom an image

Flutter tips Published on

Ever wanted to let users zoom into an image or move it around in your Flutter app?

There's a super handy widget for that called InteractiveViewer.

What is InteractiveViewer?

Flutter's InteractiveViewer widget is designed to make its child widget interactive. It lets users zoom, pan (move), and even apply transformations to the content inside it.

It works with any widget, not just images!

How to Use It with an Image

You can wrap an image widget with InteractiveViewer. Here's a simple example:

InteractiveViewer(
  key: previewWidgetKey, // An optional key
  transformationController: TransformationController(), // Controls the transformation
  scaleEnabled: true, // Allow scaling (zooming)
  constrained: false, // Set to true if the child fills the viewport
  panEnabled: true, // Allow panning (moving)
  clipBehavior: Clip.antiAlias, // How to clip content outside bounds
  child: Image.asset("name_of_your_image.png"), // Your widget here
)

In this code:

Understanding Zoom (Scaling)

The InteractiveViewer adjusts the scale value. This value determines how big the child widget appears:

How Transformations Work (A little technical detail)

The movement, zoom, and other changes are handled by a Matrix4. Think of this as a special grid of numbers (4x4) that tells the widget how to appear on the screen.

Parts of the Matrix4

[ m00 m01 m02 m03 ] [ m10 m11 m12 m13 ] [ m20 m21 m22 m23 ] [ m30 m31 m32 m33 ]

What Each Part Does

Using InteractiveViewer simplifies all of this complex matrix math for you, so you can easily add zoom and pan features!

Save 3 months of work

Create your app using our 6 years of making Flutter apps and more than 50+ apps

kickstarter for flutter apps

Frequently Asked Questions

What is the main purpose of the InteractiveViewer widget?

The main purpose is to allow users to interact with a child widget by zooming, panning (moving), and transforming it.

Can I only use InteractiveViewer with images?

No, you can use the InteractiveViewer widget with any other widget in Flutter, not just images.

Read more
You may also be interested in
What are render objects  blog card image
What are render objects
Published on 2025-06-18T12:07:12.212Z
Usefull VSCode configurations to save time  blog card image
Usefull VSCode configurations to save time
Published on 2025-06-18T12:03:45.740Z
ApparenceKit is a flutter template generator tool by Apparence.io © 2025.
All rights reserved