ConstrainedBoxModifier class
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 const BoxConstraints(minHeight: 50.0)
as the
constraints.
{@tool snippet}
This snippet makes the child widget (a Card with some Text) fill the parent, by applying BoxConstraints.expand constraints:
ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: const Card(child: Text('Hello World!')),
)
{@end-tool}
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 an Alignment value.
- 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.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- SingleChildStatelessModifier
- ConstrainedBoxModifier
- Available extensions
Constructors
- ConstrainedBoxModifier({Key? key, Widget? child, Key? modifierKey, required BoxConstraints constraints})
- Creates a widget that imposes additional constraints on its child.
Properties
- constraints → BoxConstraints
-
The additional constraints to impose on the child.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- modifierKey → Key?
-
The actual key of the widget, which Modifier wrapped
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
buildWithChild(
BuildContext context, Widget? child) → Widget -
A build method that receives an extra
child
parameter.override -
createElement(
) → SingleChildStatelessElement -
Create a SingleChildStatelessElement
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
modified(
) → Modifier -
Available on Widget, provided by the ModifierTransformer extension
Transform normal widget to Modifier -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited