View class

Bootstraps a render tree that is rendered into the provided FlutterView.

The content rendered into that view is determined by the provided child. Descendants within the same LookupBoundary can look up the view they are rendered into via View.of and View.maybeOf.

The provided child is wrapped in a MediaQuery constructed from the given view.

For most use cases, using MediaQuery.of, or its associated "...Of" methods are a more appropriate way of obtaining the information that a FlutterView exposes. For example, using MediaQuery.sizeOf will expose the logical device size (MediaQueryData.size) rather than the physical size (FlutterView.physicalSize). Similarly, while FlutterView.padding conveys the information from the operating system, the MediaQueryData.padding attribute (obtained from MediaQuery.paddingOf) further adjusts this information to be aware of the context of the widget; e.g. the Scaffold widget adjusts the values for its various children.

Each FlutterView can be associated with at most one View widget in the widget tree. Two or more View widgets configured with the same FlutterView must never exist within the same widget tree at the same time. This limitation is enforced by a GlobalObjectKey that derives its identity from the view provided to this widget.

Since the View widget bootstraps its own independent render tree, neither it nor any of its descendants will insert a RenderObject into an existing render tree. Therefore, the View widget can only be used in those parts of the widget tree where it is not required to participate in the construction of the surrounding render tree. In other words, the widget may only be used in a non-rendering zone of the widget tree (see WidgetsBinding for a definition of rendering and non-rendering zones).

In practical terms, the widget is typically used at the root of the widget tree outside of any other View widget, as a child of a ViewCollection widget, or in the ViewAnchor.view slot of a ViewAnchor widget. It is not required to be a direct child, though, since other non-RenderObjectWidgets (e.g. InheritedWidgets, Builders, or StatefulWidgets/StatelessWidget that only produce non-RenderObjectWidgets) are allowed to be present between those widgets and the View widget.

See also:



View({Key? key, required FlutterView view, @Deprecated('Do not use. ' 'This parameter only exists to implement the deprecated RendererBinding.pipelineOwner property until it is removed. ' 'This feature was deprecated after v3.10.0-12.0.pre.') PipelineOwner? deprecatedDoNotUseWillBeRemovedWithoutNoticePipelineOwner, @Deprecated('Do not use. ' 'This parameter only exists to implement the deprecated RendererBinding.renderView property until it is removed. ' 'This feature was deprecated after v3.10.0-12.0.pre.') RenderView? deprecatedDoNotUseWillBeRemovedWithoutNoticeRenderView, required Widget child})
Create a View widget to bootstrap a render tree that is rendered into the provided FlutterView.


child Widget
The widget below this widget in the tree, which will be drawn into the view.
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
view FlutterView
The FlutterView into which child is drawn.


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent 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.


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

Static Methods

maybeOf(BuildContext context) FlutterView?
Returns the FlutterView that the provided context will render into.
of(BuildContext context) FlutterView
Returns the FlutterView that the provided context will render into.
pipelineOwnerOf(BuildContext context) PipelineOwner
Returns the PipelineOwner parent to which a child View should attach its PipelineOwner to.