Skip to main content

UnconstrainedBox

Struct UnconstrainedBox 

Source
pub struct UnconstrainedBox {
    pub key: Option<KeyRef>,
    pub text_direction: Option<TextDirection>,
    pub alignment: AlignmentGeometry,
    pub constrained_axis: Option<Axis>,
    pub clip_behavior: Clip,
    pub child: Option<WidgetRef>,
}
Expand description

A widget that imposes no constraints on its child, allowing it to render at its “natural” size.

This allows a child to render at the size it would render if it were alone on an infinite canvas with no constraints. This container will then attempt to adopt the same size, within the limits of its own constraints. If it ends up with a different size, it will align the child based on alignment. If the box cannot expand enough to accommodate the entire child, the child will be clipped.

See also:

  • ConstrainedBox, for a box which imposes constraints on its child.
  • Align, which loosens the constraints given to the child rather than removing them entirely.
  • Container, a convenience widget that combines common painting, positioning, and sizing widgets.
  • OverflowBox, a widget that imposes different constraints on its child than it gets from its parent, possibly allowing the child to overflow the parent.
  • ConstraintsTransformBox, a widget that sizes its child using a transformed BoxConstraints.

Fields§

§key: Option<KeyRef>§text_direction: Option<TextDirection>

The text direction to use when interpreting the alignment if it is an AlignmentDirectional.

§alignment: AlignmentGeometry

The alignment to use when laying out the child.

If this is an AlignmentDirectional, then text_direction must not be None.

See also:

  • Alignment for non-Directionality-aware alignments.
  • AlignmentDirectional for Directionality-aware alignments.
§constrained_axis: Option<Axis>

The axis to retain constraints on, if any.

If not set, or set to None (the default), neither axis will retain its constraints. If set to Axis::Vertical, then vertical constraints will be retained, and if set to Axis::Horizontal, then horizontal constraints will be retained.

§clip_behavior: Clip

How to clip a child that overflows this box.

Defaults to Clip::None.

§child: Option<WidgetRef>

Implementations§

Source§

impl UnconstrainedBox

Source

pub fn new() -> UnconstrainedBox

Creates a widget that imposes no constraints on its child, allowing it to render at its “natural” size; Dart’s named arguments are the setters.

Source

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

Dart UnconstrainedBox(key:).

Source

pub fn text_direction(self, text_direction: TextDirection) -> UnconstrainedBox

Dart UnconstrainedBox(textDirection:).

Source

pub fn alignment(self, alignment: AlignmentGeometry) -> UnconstrainedBox

Dart UnconstrainedBox(alignment:).

Source

pub fn constrained_axis(self, constrained_axis: Axis) -> UnconstrainedBox

Dart UnconstrainedBox(constrainedAxis:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> UnconstrainedBox

Dart UnconstrainedBox(clipBehavior:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> UnconstrainedBox

Dart UnconstrainedBox(child:).

Trait Implementations§

Source§

impl Debug for UnconstrainedBox

Source§

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

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

impl Default for UnconstrainedBox

Source§

fn default() -> UnconstrainedBox

Returns the “default value” for a type. Read more
Source§

impl StatelessWidget for UnconstrainedBox

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 key(&self) -> Option<&KeyRef>

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_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
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.

Auto Trait Implementations§

§

impl !RefUnwindSafe for UnconstrainedBox

§

impl !Send for UnconstrainedBox

§

impl !Sync for UnconstrainedBox

§

impl !UnwindSafe for UnconstrainedBox

§

impl Forget for UnconstrainedBox

§

impl Freeze for UnconstrainedBox
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,

§

impl Move for UnconstrainedBox

§

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

§

impl UnsafeUnpin for UnconstrainedBox
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,

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>