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, a FocusScope, and a RawView widget.

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 or RawView widget in the widget tree. Two or more View or RawView 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 using its embedded RawView, 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 or RawView 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/StatelessWidgets that only produce non-RenderObjectWidgets) are allowed to be present between those widgets and the View widget.

See also:

Inheritance

Constructors

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.

Properties

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

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<View>
Creates the mutable state for this widget at a given location in the tree.
override
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}) 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

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.