Skip to main content

ParentData

Trait ParentData 

Source
pub trait ParentData:
    Any
    + Debug
    + Display {
    // Provided methods
    fn detach(&mut self) { ... }
    fn provide(&self, id: TypeId) -> Option<&dyn Any> { ... }
    fn provide_mut(&mut self, id: TypeId) -> Option<&mut dyn Any> { ... }
}
Expand description

Data associated with a child by its parent.

Flutter’s counterpart is the ParentData class. Subclasses are ordinary Rust types that implement this trait.

Provided Methods§

Source

fn detach(&mut self)

Called when the render object is removed from the tree.

Source

fn provide(&self, id: TypeId) -> Option<&dyn Any>

The half of this parent data whose type is id, if it embeds one.

Dart’s parentData as BoxParentData and parentData is KeepAliveParentDataMixin: a half answers for its own type, and a type that embeds one answers for its own type first and then asks the half, so a chain of halves composes. Every box parent must answer crate::BoxParentData, or a child of it cannot be positioned by the box protocol.

Source

fn provide_mut(&mut self, id: TypeId) -> Option<&mut dyn Any>

See provide; mirrors it exactly.

Implementations§

Source§

impl dyn ParentData

Source

pub fn part<P: 'static>(&self) -> Option<&P>

The P half of this parent data: the value itself when it is a P, else what provide answers.

Source

pub fn part_mut<P: 'static>(&mut self) -> Option<&mut P>

The P half of this parent data, mutably: see part.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§