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.bottomandScaffold.appBar, which require preferred size widgets.PreferredSizeWidget, the interface which this widget implements to expose its preferred size.AppBarandTabBar, which implement PreferredSizeWidget.
Implementations§
Source§impl PreferredSize
impl PreferredSize
Sourcepub fn new<K>(
preferred_size: impl Into<AnySize>,
child: impl IntoWidget<K>,
) -> PreferredSize
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.
Sourcepub fn key(self, key: KeyRef) -> PreferredSize
pub fn key(self, key: KeyRef) -> PreferredSize
Dart PreferredSize(key:).
Trait Implementations§
Source§impl Debug for PreferredSize
impl Debug for PreferredSize
Source§impl PreferredSizeWidget for PreferredSize
impl PreferredSizeWidget for PreferredSize
Source§fn preferred_size(&self) -> AnySize
fn preferred_size(&self) -> AnySize
The size this widget would prefer if it were otherwise unconstrained. Read more
Source§impl StatelessWidget for PreferredSize
impl StatelessWidget for PreferredSize
Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
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
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,
)
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)
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 PreferredSizewhere
*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
impl UnsafeUnpin for PreferredSizewhere
*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> 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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
The widget as a tree node, made where this is called: its
creation_location.