An immutable description of how to paint a box.

The following example uses the Container widget from the widgets layer to draw a background image with a border:

new Container(
  decoration: new BoxDecoration(
    backgroundColor: const Color(0xff7c94b6),
    backgroundImage: new BackgroundImage(
      image: new ExactAssetImage('images/flowers.jpeg'),
      fit: ImageFit.cover,
    border: new Border.all(
      width: 8.0,

Static Methods

lerp(BoxDecoration a, BoxDecoration b, double t) BoxDecoration

Linearly interpolate between two box decorations.


BoxDecoration({Color backgroundColor, BackgroundImage backgroundImage, Border border, BorderRadius borderRadius, List<BoxShadow> boxShadow, Gradient gradient, BoxShape shape: BoxShape.rectangle })

Creates a box decoration.



backgroundColor Color

The color to fill in the background of the box.

backgroundImage BackgroundImage

An image to paint above the background color. If shape is then the image is clipped to the circle's boundary.

border Border

A border to draw above the background.

borderRadius BorderRadius

If non-null, the corners of this box are rounded by this BorderRadius.

boxShadow List<BoxShadow>

A list of shadows cast by this box behind the background.

gradient Gradient

A gradient to use when filling the background.

hashCode int

isComplex bool

padding EdgeInsets

The inset space occupied by the border.

shape BoxShape

The shape to fill the background color into and to cast as a shadow.

runtimeType Type

A representation of the runtime type of the object.

read-only, inherited


operator ==(other) bool

The equality operator.


createBoxPainter([VoidCallback onChanged ]) → _BoxDecorationPainter

Returns a BoxPainter that will paint this decoration.

debugAssertIsValid() bool

In checked mode, throws an exception if the object is not in a valid configuration. Otherwise, returns true.

hitTest(Size size, Point position) bool

Tests whether the given point, on a rectangle of a given size, would be considered to hit the decoration or not. For example, if the decoration only draws a circle, this function might return true if the point was inside the circle and false otherwise.

lerpFrom(Decoration a, double t) BoxDecoration

Linearly interpolates from a to this.

lerpTo(Decoration b, double t) BoxDecoration

Linearly interpolates from this to b.

scale(double factor) BoxDecoration

Returns a new box decoration that is scaled by the given factor.

toString([String prefix = '', String indentPrefix ]) String

Stringifies the BoxDecoration. By default, the output will be on one line. If the method is passed a non-empty string argument, then the output will span multiple lines, each prefixed by that argument.

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.