pub struct View {
pub key: Option<KeyRef>,
pub view: ViewRef,
pub child: WidgetRef,
}Expand description
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::maybe_of.
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 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 GlobalKey
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).
Fields§
§key: Option<KeyRef>§view: ViewRefThe FlutterView into which child is drawn.
child: WidgetRefThe widget below this widget in the tree, which will be drawn into the
view.
Implementations§
Source§impl View
impl View
Sourcepub fn new<K>(view: ViewRef, child: impl IntoWidget<K>) -> View
pub fn new<K>(view: ViewRef, child: impl IntoWidget<K>) -> View
Create a View widget to bootstrap a render tree that is rendered into the provided
FlutterView.
Sourcepub fn maybe_of(app: &mut App, context: BuildContext) -> Option<ViewRef>
pub fn maybe_of(app: &mut App, context: BuildContext) -> Option<ViewRef>
Returns the FlutterView that the provided context will render into.
Returns None if the context is not associated with a FlutterView.
The method creates a dependency on the context, which will be informed when the
identity of the FlutterView changes (i.e. the context is moved to render into a
different FlutterView then before). The dependency is not triggered when the
properties on the FlutterView itself change.
Sourcepub fn of(app: &mut App, context: BuildContext) -> ViewRef
pub fn of(app: &mut App, context: BuildContext) -> ViewRef
Returns the FlutterView that the provided context will render into.
Throws if the context is not associated with a FlutterView.
The method creates a dependency on the context, which will be informed when the
identity of the FlutterView changes (i.e. the context is moved to render into a
different FlutterView then before). The dependency is not triggered when the
properties on the FlutterView itself change.
Sourcepub fn maybe_id_of(app: &App, context: BuildContext) -> Option<ViewId>
pub fn maybe_id_of(app: &App, context: BuildContext) -> Option<ViewId>
The id of the view context renders into, or None for a context in no view: above
every View, in a test’s tree without one, or no longer in the tree.
Unlike View::maybe_of, this creates no dependency, so it may be asked outside a build,
as when a ticker is created or its state activated.
Sourcepub fn pipeline_owner_of(
app: &mut App,
context: BuildContext,
) -> Handle<PipelineOwner>
pub fn pipeline_owner_of( app: &mut App, context: BuildContext, ) -> Handle<PipelineOwner>
Returns the PipelineOwner parent to which a child View should attach its
PipelineOwner to.
If context has a View ancestor, it returns the PipelineOwner that manages the
render tree of that view. If there is no View ancestor,
RendererBinding.rootPipelineOwner is returned instead.
Trait Implementations§
Source§impl StatefulWidget for View
impl StatefulWidget for View
Source§fn create_state(&self) -> ViewState
fn create_state(&self) -> ViewState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for View
impl !Send for View
impl !Sync for View
impl !UnwindSafe for View
impl Forget for View
impl Freeze for View
impl Move for View
impl Unpin for View
impl UnsafeUnpin for Viewwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn View> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn View>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.