SnapshotWidget class Null safety

A widget that can replace its child with a snapshotted version of the child.

A snapshot is a frozen texture-backed representation of all child pictures and layers stored as a ui.Image.

This widget is useful for performing short animations that would otherwise be expensive or that cannot rely on raster caching. For example, scale and skew animations are often expensive to perform on complex children, as are blurs. For a short animation, a widget that contains these expensive effects can be replaced with a snapshot of itself and manipulated instead.

For example, the Android Q ZoomPageTransitionsBuilder uses a snapshot widget for the forward and entering route to avoid the expensive scale animation. This also has the effect of briefly pausing any animations on the page.

Generally, this widget should not be used in places where users expect the child widget to continue animating or to be responsive, such as an unbounded animation.


  • The contents of platform views cannot be captured by a snapshot widget. If a platform view is encountered, then the snapshot widget will determine how to render its children based on the SnapshotMode. This defaults to SnapshotMode.normal which will throw an exception if a platform view is encountered.

  • The snapshotting functionality of this widget is not supported on the HTML backend of Flutter for the Web. Setting SnapshotController.allowSnapshotting to true may cause an error to be thrown. On the CanvasKit backend of Flutter, the performance of using this widget may regress performance due to the fact that both the UI and engine share a single thread.



SnapshotWidget({Key? key, SnapshotMode mode = SnapshotMode.normal, SnapshotPainter painter = const _DefaultSnapshotPainter(), bool autoresize = false, required SnapshotController controller, required Widget? child})
Create a new SnapshotWidget.


autoresize bool
Whether or not changes in render object size should automatically re-create the snapshot.
child Widget?
The widget below this widget in the tree.
controller SnapshotController
The controller that determines when to display the children as a snapshot.
hashCode int
The hash code for this object.
key Key?
Controls how one widget replaces another widget in the tree.
mode SnapshotMode
Configuration that controls how the snapshot widget decides to paint its children.
painter SnapshotPainter
The painter used to paint the child snapshot or child widgets.
runtimeType Type
A representation of the runtime type of the object.


createElement() SingleChildRenderObjectElement
RenderObjectWidgets always inflate to a RenderObjectElement subclass.
createRenderObject(BuildContext context) RenderObject
Creates an instance of the RenderObject class that this RenderObjectWidget represents, using the configuration described by this RenderObjectWidget.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
didUnmountRenderObject(covariant RenderObject renderObject) → void
A render object previously associated with this widget has been removed from the tree. The given RenderObject will be of the same type as returned by this object's createRenderObject.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
toStringShort() String
A short, textual description of this widget.
updateRenderObject(BuildContext context, covariant RenderObject renderObject) → void
Copies the configuration described by this RenderObjectWidget to the given RenderObject, which will be of the same type as returned by this object's createRenderObject.


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