VxSizedBoxExtension extension

A box with a specified size.

If given a child, this widget forces its child to have a specific width and/or height (assuming values are permitted by this widget's parent). If either the width or height is null, this widget will try to size itself to match the child's size in that dimension. If the child's size depends on the size of its parent, the height and width must be provided.

If not given a child, SizedBox will try to size itself as close to the specified height and width as possible given the parent's constraints. If height or width is null or unspecified, it will be treated as zero.

The SizedBox.expand constructor can be used to make a SizedBox that sizes itself to fit the parent. It is equivalent to setting width and height to double.infinity.

{@tool snippet}

This snippet makes the child widget (a Card with some Text) have the exact size 200x300, parental constraints permitting:

SizedBox(
  width: 200.0,
  height: 300.0,
  child: const Card(child: Text('Hello World!')),
)

{@end-tool}

See also:

  • ConstrainedBox, a more generic version of this class that takes arbitrary BoxConstraints instead of an explicit width and height.
  • UnconstrainedBox, a container that tries to let its child draw without constraints.
  • FractionallySizedBox, a widget that sizes its child to a fraction of the total available space.
  • AspectRatio, a widget that attempts to fit within the parent's constraints while also sizing its child to match a given aspect ratio.
  • FittedBox, which sizes and positions its child widget to fit the parent according to a given BoxFit discipline.
  • The catalog of layout widgets.
on

Methods

fractionalBox({Key? key, required double heightFactor, required double widthFactor, Alignment? alignment}) Widget
Extension for FractionallySizedBox
h(double height) Widget
All available heights SizedBox widget with a specified height
h0(BuildContext context, {Key? key}) Widget
SizedBox widget with 0% height of the MediaQuery height
h1(BuildContext context, {Key? key}) Widget
SizedBox widget with 1% height of the MediaQuery height
h10(BuildContext context, {Key? key}) Widget
SizedBox widget with 10% height of the MediaQuery height
h15(BuildContext context, {Key? key}) Widget
SizedBox widget with 15% height of the MediaQuery height
h16(BuildContext context, {Key? key}) Widget
SizedBox widget with 16% height of the MediaQuery height
h2(BuildContext context, {Key? key}) Widget
SizedBox widget with 2% height of the MediaQuery height
h20(BuildContext context, {Key? key}) Widget
SizedBox widget with 20% height of the MediaQuery height
h24(BuildContext context, {Key? key}) Widget
SizedBox widget with 24% height of the MediaQuery height
h32(BuildContext context, {Key? key}) Widget
SizedBox widget with 32% height of the MediaQuery height
h4(BuildContext context, {Key? key}) Widget
SizedBox widget with 4% height of the MediaQuery height
h40(BuildContext context, {Key? key}) Widget
SizedBox widget with 40% height of the MediaQuery height
h48(BuildContext context, {Key? key}) Widget
SizedBox widget with 48% height of the MediaQuery height
h56(BuildContext context, {Key? key}) Widget
SizedBox widget with 56% height of the MediaQuery height
h60(BuildContext context, {Key? key}) Widget
SizedBox widget with 60% height of the MediaQuery height
h64(BuildContext context, {Key? key}) Widget
SizedBox widget with 64% height of the MediaQuery height
h8(BuildContext context, {Key? key}) Widget
SizedBox widget with 8% height of the MediaQuery height
hFourFifth(BuildContext context, {Key? key}) Widget
SizedBox widget with four-fifth or 80% height of the MediaQuery height
hFull(BuildContext context, {Key? key}) Widget
SizedBox widget with full height of the MediaQuery height
hHalf(BuildContext context, {Key? key}) Widget
SizedBox widget with half or 50% height of the MediaQuery height
hOneForth(BuildContext context, {Key? key}) Widget
SizedBox widget with one-forth or 25% height of the MediaQuery height
hOneThird(BuildContext context, {Key? key}) Widget
SizedBox widget with one-third or 33.33% height of the MediaQuery height
hPCT({required BuildContext context, required double heightPCT}) Widget
SizedBox widget with a specified height percentage
hThreeForth(BuildContext context, {Key? key}) Widget
SizedBox widget with three-forth or 75% height of the MediaQuery height
hTwoThird(BuildContext context, {Key? key}) Widget
SizedBox widget with two-third or 66.67% height of the MediaQuery height
w(double width, {Key? key}) Widget
All available widths
w0(BuildContext context, {Key? key}) Widget
SizedBox widget with 0% width of the MediaQuery width
w1(BuildContext context, {Key? key}) Widget
SizedBox widget with 1% width of the MediaQuery width
w10(BuildContext context, {Key? key}) Widget
SizedBox widget with 10% width of the MediaQuery width
w15(BuildContext context, {Key? key}) Widget
SizedBox widget with 15% width of the MediaQuery width
w16(BuildContext context, {Key? key}) Widget
SizedBox widget with 16% width of the MediaQuery width
w2(BuildContext context, {Key? key}) Widget
SizedBox widget with 2% width of the MediaQuery width
w20(BuildContext context, {Key? key}) Widget
SizedBox widget with 20% width of the MediaQuery width
w24(BuildContext context, {Key? key}) Widget
SizedBox widget with 24% width of the MediaQuery width
w32(BuildContext context, {Key? key}) Widget
SizedBox widget with 32% width of the MediaQuery width
w4(BuildContext context, {Key? key}) Widget
SizedBox widget with 4% width of the MediaQuery width
w40(BuildContext context, {Key? key}) Widget
SizedBox widget with 40% width of the MediaQuery width
w48(BuildContext context, {Key? key}) Widget
SizedBox widget with 48% width of the MediaQuery width
w56(BuildContext context, {Key? key}) Widget
SizedBox widget with 56% width of the MediaQuery width
w60(BuildContext context, {Key? key}) Widget
SizedBox widget with 60% width of the MediaQuery width
w64(BuildContext context, {Key? key}) Widget
SizedBox widget with 64% width of the MediaQuery width
w8(BuildContext context, {Key? key}) Widget
SizedBox widget with 8% width of the MediaQuery width
wFourFifth(BuildContext context, {Key? key}) Widget
SizedBox widget with four-fifth or 80% width of the MediaQuery width
wFull(BuildContext context, {Key? key}) Widget
SizedBox widget with full width of the MediaQuery width
wh(double width, double height) Widget
All Size Width - Height
wh0(BuildContext context, {Key? key}) Widget
SizedBox widget with 0% width & height of the MediaQuery width & height
wh1(BuildContext context, {Key? key}) Widget
SizedBox widget with 1% width & height of the MediaQuery width & height
wh10(BuildContext context, {Key? key}) Widget
SizedBox widget with 10% width & height of the MediaQuery width & height
wh15(BuildContext context, {Key? key}) Widget
SizedBox widget with 15% width & height of the MediaQuery width & height
wh16(BuildContext context, {Key? key}) Widget
SizedBox widget with 16% width & height of the MediaQuery width & height
wh2(BuildContext context, {Key? key}) Widget
SizedBox widget with 2% width & height of the MediaQuery width & height
wh20(BuildContext context, {Key? key}) Widget
SizedBox widget with 20% width & height of the MediaQuery width & height
wh24(BuildContext context, {Key? key}) Widget
SizedBox widget with 24% width & height of the MediaQuery width & height
wh32(BuildContext context, {Key? key}) Widget
SizedBox widget with 32% width & height of the MediaQuery width & height
wh4(BuildContext context, {Key? key}) Widget
SizedBox widget with 4% width & height of the MediaQuery width & height
wh40(BuildContext context, {Key? key}) Widget
SizedBox widget with 40% width & height of the MediaQuery width & height
wh48(BuildContext context, {Key? key}) Widget
SizedBox widget with 48% width & height of the MediaQuery width & height
wh56(BuildContext context, {Key? key}) Widget
SizedBox widget with 56% width & height of the MediaQuery width & height
wh60(BuildContext context, {Key? key}) Widget
SizedBox widget with 60% width & height of the MediaQuery width & height
wh64(BuildContext context, {Key? key}) Widget
SizedBox widget with 64% width & height of the MediaQuery width & height
wh8(BuildContext context, {Key? key}) Widget
SizedBox widget with 8% width & height of the MediaQuery width & height
wHalf(BuildContext context, {Key? key}) Widget
SizedBox widget with half or 50% width of the MediaQuery width
whFourFifth(BuildContext context, {Key? key}) Widget
SizedBox widget with four-fifth or 80% width & height of the MediaQuery width & height
whFull(BuildContext context, {Key? key}) Widget
SizedBox widget with full width & height of the MediaQuery width & height
whHalf(BuildContext context, {Key? key}) Widget
SizedBox widget with half or 50% width & height of the MediaQuery width & height
whOneForth(BuildContext context, {Key? key}) Widget
SizedBox widget with one-forth or 25% width & height of the MediaQuery width & height
whOneThird(BuildContext context, {Key? key}) Widget
SizedBox widget with one-third or 33.33% width & height of the MediaQuery width & height
whPCT({required BuildContext context, required double widthPCT, required double heightPCT}) Widget
SizedBox widget with a specified width & height percentage
whThreeForth(BuildContext context, {Key? key}) Widget
SizedBox widget with three-forth or 75% width & height of the MediaQuery width & height
whTwoThird(BuildContext context, {Key? key}) Widget
SizedBox widget with two-third or 66.67% width & height of the MediaQuery width & height
wOneForth(BuildContext context, {Key? key}) Widget
SizedBox widget with one-forth or 25% width of the MediaQuery width
wOneThird(BuildContext context, {Key? key}) Widget
SizedBox widget with one-third or 33.33% width of the MediaQuery width
wPCT({required BuildContext context, required double widthPCT}) Widget
SizedBox widget with a specified width percentage
wThreeForth(BuildContext context, {Key? key}) Widget
SizedBox widget with three-forth or 75% width of the MediaQuery width
wTwoThird(BuildContext context, {Key? key}) Widget
SizedBox widget with two-third or 66.67% width of the MediaQuery width