Skip to main content

PreferredSize

Struct PreferredSize 

Source
pub struct PreferredSize { /* private fields */ }
Expand description

A widget with a preferred size.

This widget does not impose any constraints on its child, and it doesn’t affect the child’s layout in any way. It just advertises a preferred size which can be used by the parent.

Parents like Scaffold use PreferredSizeWidget to require that their children implement that interface. To give a preferred size to an arbitrary widget so that it can be used in a child property of that type, this widget, PreferredSize, can be used.

Widgets like AppBar implement a PreferredSizeWidget, so that this PreferredSize widget is not necessary for them.

See also:

  • AppBar.bottom and Scaffold.appBar, which require preferred size widgets.
  • PreferredSizeWidget, the interface which this widget implements to expose its preferred size.
  • AppBar and TabBar, which implement PreferredSizeWidget.

Implementations§

Source§

impl PreferredSize

Source

pub fn new<K>( preferred_size: impl Into<AnySize>, child: impl IntoWidget<K>, ) -> PreferredSize

Creates a widget that has a preferred size that the parent can query.

Source

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

Dart PreferredSize(key:).

Trait Implementations§

Source§

impl Debug for PreferredSize

Source§

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

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

impl PreferredSizeWidget for PreferredSize

Source§

fn preferred_size(&self) -> AnySize

The size this widget would prefer if it were otherwise unconstrained. Read more
Source§

impl StatelessWidget for PreferredSize

Source§

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

Source§

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

Dart’s this is PreferredSizeWidget: a widget that implements PreferredSizeWidget answers with itself, which is what a parent asking an erased child for its preferred size reads.
Source§

fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. 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)

Dart’s constructor asserts that relate two or more arguments. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for PreferredSize

§

impl !Send for PreferredSize

§

impl !Sync for PreferredSize

§

impl !UnwindSafe for PreferredSize

§

impl Forget for PreferredSize

§

impl Freeze for PreferredSize
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn SizeExtension> is !null: Freeze, PhantomData<RcInner<dyn SizeExtension>>: Freeze,

§

impl Move for PreferredSize

§

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

§

impl UnsafeUnpin for PreferredSize
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn SizeExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn SizeExtension>>: 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<StatelessKind> for W
where W: StatelessWidget,

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>