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(
      color: Colors.black,
      width: 8.0,
    ),
  ),
)
Inheritance

Static Methods

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

Linearly interpolate between two box decorations.

Constructors

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

Creates a box decoration.

const

Properties

backgroundColor Color

The color to fill in the background of the box.

read-only
backgroundImage BackgroundImage

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

read-only
border Border

A border to draw above the background.

read-only
borderRadius BorderRadius

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

read-only
boxShadow List<BoxShadow>

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

read-only
gradient Gradient

A gradient to use when filling the background.

read-only
hashCode int

read-only
isComplex bool

read-only
padding EdgeInsets

The inset space occupied by the border.

read-only
shape BoxShape

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

read-only
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) bool

The equality operator.

Methods

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.

inherited