pub struct ConstrainedBox {
pub key: Option<KeyRef>,
pub constraints: BoxConstraints,
pub child: Option<WidgetRef>,
}Expand description
A widget that imposes additional constraints on its child.
For example, if you wanted child to have a minimum height of 50.0 logical
pixels, you could use BoxConstraints::new().min_height(50.0) as the
constraints.
This snippet makes the child widget (a Card with some Text) fill the
parent, by applying BoxConstraints.expand constraints:
ConstrainedBox {
constraints: BoxConstraints::expand(),
child: Some(Card(child: Text("Hello World!"))),
key: None,
}The same behavior can be obtained using the SizedBox::expand widget.
See also:
BoxConstraints, the class that describes constraints.UnconstrainedBox, a container that tries to let its child draw without constraints.SizedBox, which lets you specify tight constraints by explicitly specifying the height or width.FractionallySizedBox, which sizes its child based on a fraction of its own size and positions the child according to anAlignmentvalue.AspectRatio, a widget that attempts to fit within the parent’s constraints while also sizing its child to match a given aspect ratio.- The catalog of layout widgets.
Fields§
§key: Option<KeyRef>§constraints: BoxConstraintsThe additional constraints to impose on the child.
Must be valid (BoxConstraints::debug_assert_is_valid).
child: Option<WidgetRef>Implementations§
Source§impl ConstrainedBox
impl ConstrainedBox
Sourcepub fn new(constraints: BoxConstraints) -> ConstrainedBox
pub fn new(constraints: BoxConstraints) -> ConstrainedBox
Creates a ConstrainedBox; Dart’s optional named arguments are the setters.
Sourcepub fn key(self, key: KeyRef) -> ConstrainedBox
pub fn key(self, key: KeyRef) -> ConstrainedBox
Dart ConstrainedBox(key:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> ConstrainedBox
pub fn child<K>(self, child: impl IntoWidget<K>) -> ConstrainedBox
Dart ConstrainedBox(child:).
Trait Implementations§
Source§impl Debug for ConstrainedBox
impl Debug for ConstrainedBox
Source§impl RenderObjectWidget for ConstrainedBox
impl RenderObjectWidget for ConstrainedBox
Source§type RenderObject = RenderConstrainedBox
type RenderObject = RenderConstrainedBox
The render object this widget creates; Dart’s
covariant RenderObject parameter type.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 create_render_object(
&self,
app: &mut App,
_context: BuildContext,
) -> AnyRenderObject
fn create_render_object( &self, app: &mut App, _context: BuildContext, ) -> AnyRenderObject
Creates an instance of the
RenderObject class that this widget represents, using the
configuration described by this widget. Read moreSource§fn update_render_object(
&self,
app: &mut App,
_context: BuildContext,
render_object: RenderHandle<RenderConstrainedBox>,
)
fn update_render_object( &self, app: &mut App, _context: BuildContext, render_object: RenderHandle<RenderConstrainedBox>, )
Copies the configuration described by this widget to the given render object, which
will be of the same type as returned by this object’s
create_render_object. Read moreSource§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Dart’s
toStringShort, for a widget that names itself apart from its type, as
SizedBox.expand does; see Widget::to_string_short.Source§fn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )
Dart’s
debugVisitOnstageChildren of the element this widget makes, for a widget whose
Dart element subclass overrides it only to hide children (_OffstageElement,
_IndexedStackElement): calls visitor for each of children, in order, that is
onstage. Waft’s generic single- and multi-child elements stand in for those subclasses
and ask their widget here; an element of a widget’s own overrides
Element::debug_visit_onstage_children instead.Source§fn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<Self::RenderObject>,
)
fn did_unmount_render_object( &self, app: &mut App, render_object: RenderHandle<Self::RenderObject>, )
A render object previously associated with this widget has been removed from the tree.
The given
RenderObject will be of the same type as returned by this object’s
create_render_object.Auto Trait Implementations§
impl !RefUnwindSafe for ConstrainedBox
impl !Send for ConstrainedBox
impl !Sync for ConstrainedBox
impl !UnwindSafe for ConstrainedBox
impl Forget for ConstrainedBox
impl Freeze for ConstrainedBox
impl Move for ConstrainedBox
impl Unpin for ConstrainedBox
impl UnsafeUnpin for ConstrainedBoxwhere
*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> 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<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
impl<W> IntoWidget<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
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.