Container constructor

Container(
  1. {Key key,
  2. AlignmentGeometry alignment,
  3. EdgeInsetsGeometry padding,
  4. Color color,
  5. Decoration decoration,
  6. Decoration foregroundDecoration,
  7. double width,
  8. double height,
  9. BoxConstraints constraints,
  10. EdgeInsetsGeometry margin,
  11. Matrix4 transform,
  12. Widget child,
  13. Clip clipBehavior: Clip.none}
)

Creates a widget that combines common painting, positioning, and sizing widgets.

The height and width values include the padding.

The color and decoration arguments cannot both be supplied, since it would potentially result in the decoration drawing over the background color. To supply a decoration with a color, use decoration: BoxDecoration(color: color).

Implementation

Container({
  Key key,
  this.alignment,
  this.padding,
  this.color,
  this.decoration,
  this.foregroundDecoration,
  double width,
  double height,
  BoxConstraints constraints,
  this.margin,
  this.transform,
  this.child,
  this.clipBehavior = Clip.none,
}) : assert(margin == null || margin.isNonNegative),
     assert(padding == null || padding.isNonNegative),
     assert(decoration == null || decoration.debugAssertIsValid()),
     assert(constraints == null || constraints.debugAssertIsValid()),
     assert(clipBehavior != null),
     assert(color == null || decoration == null,
       'Cannot provide both a color and a decoration\n'
       'To provide both, use "decoration: BoxDecoration(color: color)".'
     ),
     constraints =
      (width != null || height != null)
        ? constraints?.tighten(width: width, height: height)
          ?? BoxConstraints.tightFor(width: width, height: height)
        : constraints,
     super(key: key);