SizedBox class

A widget with a fixed width and height.

Use SizedBox.shrink for a zero-sized box or SizedBox.square for equal dimensions. If given a child, constrains it to the specified size.

Inheritance

Constructors

SizedBox({Key? key, int width = 0, int height = 0, Widget? child})
Creates a SizedBox with the given width and height.
const
SizedBox.shrink({Key? key, Widget? child})
Creates a zero-sized box.
const
SizedBox.square({Key? key, required int dimension, Widget? child})
Creates a box with equal width and height set to dimension.
const

Properties

child Widget?
The optional child widget.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
height int
The fixed height in terminal cells.
final
key Key?
Controls how one widget replaces another in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width int
The fixed width in terminal cells.
final

Methods

createElement() SingleChildRenderObjectElement
Creates the Element for this widget.
inherited
createRenderObject(BuildContext context) RenderSizedBox
Creates the RenderObject for this widget.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
updateRenderObject(BuildContext context, RenderObject renderObject) → void
Updates the renderObject to reflect the current widget configuration.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited