pub struct ConstraintsTransformBox {
pub key: Option<KeyRef>,
pub text_direction: Option<TextDirection>,
pub alignment: AlignmentGeometry,
pub constraints_transform: BoxConstraintsTransform,
pub clip_behavior: Clip,
pub debug_transform_type: String,
pub child: Option<WidgetRef>,
}Expand description
A container widget that applies an arbitrary transform to its constraints,
and sizes its child using the resulting BoxConstraints, optionally
clipping, or treating the overflow as an error.
This container sizes its child using a BoxConstraints created by applying
constraints_transform to its own 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 container cannot expand enough to accommodate the
entire child, the child will be clipped if clip_behavior is not
Clip::None.
When child is None, this widget becomes as small as possible and never
overflows.
This widget can be used to ensure some of the child’s natural dimensions are
honored. For instance, if the child requires a minimum height to fully display its
content, constraints_transform can be set to
max_height_unconstrained, so that the child may still
grow vertically when the parent fails to provide enough vertical space:
ConstrainedBox::new(BoxConstraints::new().min_height(40.0).max_height(100.0)).child(
ConstraintsTransformBox::new(ConstraintsTransformBox::max_height_unconstrained)
.child(Text::new("Hello World!")),
)See also:
ConstrainedBox, which renders a box which imposes constraints on its child.OverflowBox, a widget that imposes additional constraints on its child, and allows the child to overflow itself.UnconstrainedBoxwhich allows its children to render themselves unconstrained and expands to fit them.
Fields§
§key: Option<KeyRef>§text_direction: Option<TextDirection>The text direction to use when interpreting the alignment if it is
an AlignmentDirectional.
Defaults to None, in which case Directionality::maybe_of is used to determine the
text direction.
alignment: AlignmentGeometryThe alignment to use when laying out the child, if it has a different size than this widget.
If this is an AlignmentDirectional, then
text_direction must not be None.
See also:
Alignmentfor non-Directionality-aware alignments.AlignmentDirectionalforDirectionality-aware alignments.
constraints_transform: BoxConstraintsTransformThe function used to transform the incoming BoxConstraints, to size
child.
The function must return a BoxConstraints that is normalized.
See ConstraintsTransformBox for predefined common
BoxConstraintsTransforms.
clip_behavior: ClipHow to clip a child that overflows this box.
Defaults to Clip::None.
debug_transform_type: StringA description of the transform to show in a dump, when it is not one of the predefined transforms this widget knows.
child: Option<WidgetRef>Implementations§
Source§impl ConstraintsTransformBox
impl ConstraintsTransformBox
Sourcepub fn new(
constraints_transform: BoxConstraintsTransform,
) -> ConstraintsTransformBox
pub fn new( constraints_transform: BoxConstraintsTransform, ) -> ConstraintsTransformBox
Creates a widget that uses a function to transform the constraints it passes to its child; Dart’s optional named arguments are the setters.
Sourcepub fn debug_transform_type(
self,
debug_transform_type: impl Into<String>,
) -> ConstraintsTransformBox
pub fn debug_transform_type( self, debug_transform_type: impl Into<String>, ) -> ConstraintsTransformBox
Dart ConstraintsTransformBox(debugTransformType:).
Sourcepub fn key(self, key: KeyRef) -> ConstraintsTransformBox
pub fn key(self, key: KeyRef) -> ConstraintsTransformBox
Dart ConstraintsTransformBox(key:).
Sourcepub fn text_direction(
self,
text_direction: TextDirection,
) -> ConstraintsTransformBox
pub fn text_direction( self, text_direction: TextDirection, ) -> ConstraintsTransformBox
Dart ConstraintsTransformBox(textDirection:).
Sourcepub fn alignment(self, alignment: AlignmentGeometry) -> ConstraintsTransformBox
pub fn alignment(self, alignment: AlignmentGeometry) -> ConstraintsTransformBox
Dart ConstraintsTransformBox(alignment:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> ConstraintsTransformBox
pub fn clip_behavior(self, clip_behavior: Clip) -> ConstraintsTransformBox
Dart ConstraintsTransformBox(clipBehavior:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> ConstraintsTransformBox
pub fn child<K>(self, child: impl IntoWidget<K>) -> ConstraintsTransformBox
Dart ConstraintsTransformBox(child:).
Sourcepub fn unmodified(constraints: BoxConstraints) -> BoxConstraints
pub fn unmodified(constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that always returns its argument as-is (i.e.,
it is an identity function).
The ConstraintsTransformBox becomes a proxy widget that has no effect on
layout if constraints_transform is set to this.
Sourcepub fn unconstrained(_constraints: BoxConstraints) -> BoxConstraints
pub fn unconstrained(_constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that always returns a BoxConstraints that
imposes no constraints on either dimension.
Setting constraints_transform to this allows
child to render at its “natural” size (equivalent to an
UnconstrainedBox with constrained_axis set to None).
Sourcepub fn width_unconstrained(constraints: BoxConstraints) -> BoxConstraints
pub fn width_unconstrained(constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that removes the width constraints from the
input.
Setting constraints_transform to this allows
child to render at its “natural” width (equivalent to an
UnconstrainedBox with constrained_axis set to Axis::Horizontal).
Sourcepub fn height_unconstrained(constraints: BoxConstraints) -> BoxConstraints
pub fn height_unconstrained(constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that removes the height constraints from the
input.
Setting constraints_transform to this allows
child to render at its “natural” height (equivalent to an
UnconstrainedBox with constrained_axis set to Axis::Vertical).
Sourcepub fn max_height_unconstrained(constraints: BoxConstraints) -> BoxConstraints
pub fn max_height_unconstrained(constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that removes the max_height constraint from
the input.
Setting constraints_transform to this allows
child to render at its “natural” height or the min_height of the
incoming BoxConstraints, whichever is larger.
Sourcepub fn max_width_unconstrained(constraints: BoxConstraints) -> BoxConstraints
pub fn max_width_unconstrained(constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that removes the max_width constraint from
the input.
Setting constraints_transform to this allows
child to render at its “natural” width or the min_width of the
incoming BoxConstraints, whichever is larger.
Sourcepub fn max_unconstrained(constraints: BoxConstraints) -> BoxConstraints
pub fn max_unconstrained(constraints: BoxConstraints) -> BoxConstraints
A BoxConstraintsTransform that removes both the max_width and the
max_height constraints from the input.
Setting constraints_transform to this allows
child to render at least its “natural” size, and grow along an axis if
the incoming BoxConstraints has a larger minimum constraint on that axis.
Trait Implementations§
Source§impl Debug for ConstraintsTransformBox
impl Debug for ConstraintsTransformBox
Source§impl RenderObjectWidget for ConstraintsTransformBox
impl RenderObjectWidget for ConstraintsTransformBox
Source§type RenderObject = RenderConstraintsTransformBox
type RenderObject = RenderConstraintsTransformBox
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, )
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
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<RenderConstraintsTransformBox>,
)
fn update_render_object( &self, app: &mut App, context: BuildContext, render_object: RenderHandle<RenderConstraintsTransformBox>, )
create_render_object. Read moreSource§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
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), )
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>, )
RenderObject will be of the same type as returned by this object’s
create_render_object.Auto Trait Implementations§
impl !RefUnwindSafe for ConstraintsTransformBox
impl !Send for ConstraintsTransformBox
impl !Sync for ConstraintsTransformBox
impl !UnwindSafe for ConstraintsTransformBox
impl Forget for ConstraintsTransformBox
impl Freeze for ConstraintsTransformBox
impl Move for ConstraintsTransformBox
impl Unpin for ConstraintsTransformBox
impl UnsafeUnpin for ConstraintsTransformBoxwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: 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
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>
creation_location.