Skip to main content

View

Struct View 

Source
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: ViewRef

The FlutterView into which child is drawn.

§child: WidgetRef

The widget below this widget in the tree, which will be drawn into the view.

Implementations§

Source§

impl View

Source

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.

Source

pub fn key(self, key: KeyRef) -> View

Dart View(key:).

Source

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.

Source

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.

Source

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.

Source

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 Debug for View

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for View

Source§

type State = ViewState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> ViewState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 debug_check_constructor(&self)

Source§

fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>

Source§

fn type_name(&self) -> &'static str

See 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
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn View> is !null: Freeze, PhantomData<RcInner<dyn View>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for View

§

impl Unpin for View
where Rc<dyn Key>: Unpin, Rc<dyn View>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for View
where *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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>