An immutable description of how to paint an arbitrary shape.

The ShapeDecoration class provides a way to draw a ShapeBorder, optionally filling it with a color or a gradient, optionally painting an image into it, and optionally casting a shadow.

Sample code

The following example uses the Container widget from the widgets layer to draw a white rectangle with a 24-pixel multicolor outline, with the text "RGB" inside it:

new Container(
  decoration: new ShapeDecoration(
    color: Colors.white,
    shape: new Border.all(
      color: Colors.red,
      width: 8.0,
    ) + new Border.all(
      color: Colors.green,
      width: 8.0,
    ) + new Border.all(
      color: Colors.blue,
      width: 8.0,
    ),
  ),
  child: const Text('RGB', textAlign: TextAlign.center),
)

See also:

Inheritance

Constructors

ShapeDecoration({Color color, DecorationImage image, Gradient gradient, List<BoxShadow> shadows, @required ShapeBorder shape })
Creates a shape decoration. [...]
const
ShapeDecoration.fromBoxDecoration(BoxDecoration source)
Creates a shape decoration configured to match a BoxDecoration. [...]
factory

Properties

color Color
The color to fill in the background of the shape. [...]
final
gradient Gradient
A gradient to use when filling the shape. [...]
final
hashCode int
The hash code for this object. [...]
read-only
image DecorationImage
An image to paint inside the shape (clipped to its outline). [...]
final
isComplex bool
Whether this decoration is complex enough to benefit from caching its painting.
read-only
padding EdgeInsets
The inset space occupied by the shape's border. [...]
read-only
shadows List<BoxShadow>
A list of shadows cast by this shape behind the shape.
final
shape ShapeBorder
The shape to fill the color, gradient, and image into and to cast as the shadows. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

createBoxPainter([VoidCallback onChanged ]) → _ShapeDecorationPainter
Returns a BoxPainter that will paint this decoration. [...]
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
hitTest(Size size, Offset position, { TextDirection textDirection }) 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) ShapeDecoration
Linearly interpolates from a to this. [...]
lerpTo(Decoration b, double t) ShapeDecoration
Linearly interpolates from this to b. [...]
debugAssertIsValid() bool
In checked mode, throws an exception if the object is not in a valid configuration. Otherwise, returns true. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode. [...]
inherited

Operators

operator ==(other) bool
The equality operator. [...]

Static Methods

lerp(ShapeDecoration a, ShapeDecoration b, double t) ShapeDecoration
Linearly interpolate between two shapes. [...]