FluentBoxDecoration class
A BoxDecoration whose boxShadow paints the way CSS box-shadow does:
outside the box only.
BoxDecoration draws each shadow as a blurred, filled copy of the box
under the box. An opaque color hides that, which is why a menu or a card
never shows it. A transparent or translucent box does: light-theme
shadow16 on a box with no fill washes its whole inside to about 76% of
whatever is behind it. Upstream writes boxShadow: tokens.shadow16 on
elements with no background all the time, and the browser shows the page
through them untouched.
Use this wherever upstream shadows an element that has no opaque background. Everything except the shadows is painted exactly as BoxDecoration paints it. The shadows follow CSS rather than BoxShadow.toPaint:
- they are clipped to outside the decoration's shape, the border box;
- the blur's standard deviation is half of BoxShadow.blurRadius, as the CSS spec defines it, not Shadow.convertRadiusToSigma; and
- the first shadow in the list paints on top, as in CSS, where BoxDecoration puts the last one on top.
BoxShadow.spreadRadius inflates the box without growing its corner radii, as BoxDecoration does, whereas CSS grows them by the spread. BoxShadow.blurStyle is ignored, because CSS has no equivalent.
- Inheritance
-
- Object
- Decoration
- BoxDecoration
- FluentBoxDecoration
Constructors
-
FluentBoxDecoration({Color? color, DecorationImage? image, BoxBorder? border, BorderRadiusGeometry? borderRadius, List<
BoxShadow> ? boxShadow, Gradient? gradient, BlendMode? backgroundBlendMode, BoxShape shape = BoxShape.rectangle}) -
Creates a decoration whose shadows stay outside the box.
const
Properties
- backgroundBlendMode → BlendMode?
-
The blend mode applied to the color or gradient background of the box.
finalinherited
- border → BoxBorder?
-
A border to draw above the background color, gradient, or image.
finalinherited
- borderRadius → BorderRadiusGeometry?
-
If non-null, the corners of this box are rounded by this BorderRadius.
finalinherited
-
boxShadow
→ List<
BoxShadow> ? -
A list of shadows cast by this box behind the box.
finalinherited
- color → Color?
-
The color to fill in the background of the box.
finalinherited
- gradient → Gradient?
-
A gradient to use when filling the box.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- image → DecorationImage?
-
An image to paint above the background color or gradient.
finalinherited
- isComplex → bool
-
Whether this decoration is complex enough to benefit from caching its painting.
no setterinherited
- padding → EdgeInsetsGeometry
-
Returns the insets to apply when using this decoration on a box
that has contents, so that the contents do not overlap the edges
of the decoration. For example, if the decoration draws a frame
around its edge, the padding would return the distance by which
to inset the children so as to not overlap the frame.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → BoxShape
-
The shape to fill the background color, gradient, and image into and
to cast as the boxShadow.
finalinherited
Methods
-
copyWith(
{Color? color, DecorationImage? image, BoxBorder? border, BorderRadiusGeometry? borderRadius, List< BoxShadow> ? boxShadow, Gradient? gradient, BlendMode? backgroundBlendMode, BoxShape? shape}) → BoxDecoration -
Creates a copy of this object but with the given fields replaced with the
new values.
inherited
-
createBoxPainter(
[VoidCallback? onChanged]) → BoxPainter -
Returns a BoxPainter that will paint this decoration.
override
-
debugAssertIsValid(
) → bool -
In debug mode, throws an exception if the object is not in a
valid configuration. Otherwise, returns true.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
getClipPath(
Rect rect, TextDirection textDirection) → Path -
Returns a closed Path that describes the outer edge of this decoration.
inherited
-
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.
inherited
-
lerpFrom(
Decoration? a, double t) → BoxDecoration? -
Linearly interpolates from another Decoration (which may be of a
different class) to
this.inherited -
lerpTo(
Decoration? b, double t) → BoxDecoration? -
Linearly interpolates from
thisto another Decoration (which may be of a different class).inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scale(
double factor) → BoxDecoration -
Returns a new box decoration that is scaled by the given factor.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
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 ==(
Object other) → bool -
The equality operator.
inherited