ImageViewer class

A fullscreen image viewer widget with zoom and pan support.

This widget displays an image in fullscreen with a semi-transparent background, a close button, and interactive zoom/pan capabilities.

Usage

Use showImageViewer to display the viewer:

showImageViewer(
  context: context,
  imageFile: File('/path/to/image.png'),
);

Or with a hero animation:

// In your thumbnail widget:
Hero(
  tag: 'my-image',
  child: Image.file(imageFile),
)

// To open fullscreen:
showImageViewer(
  context: context,
  imageFile: imageFile,
  heroTag: 'my-image',
);
Inheritance

Constructors

ImageViewer({Key? key, required File imageFile, String? heroTag, Color backgroundColor = Colors.black87, Color closeButtonColor = Colors.black54, Color closeIconColor = Colors.white, double minScale = 0.5, double maxScale = 4.0, VoidCallback? onClose})
Creates an ImageViewer widget.
const

Properties

backgroundColor Color
Background color of the viewer overlay.
final
closeButtonColor Color
Background color of the close button.
final
closeIconColor Color
Color of the close icon.
final
hashCode int
The hash code for this object.
no setterinherited
heroTag String?
Optional hero tag for hero animation.
final
imageFile File
The image file to display.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxScale double
Maximum scale factor for zoom.
final
minScale double
Minimum scale factor for zoom.
final
onClose VoidCallback?
Callback when the viewer is closed.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited