Unverified Commit 6dc18ef7 authored by Deepak Penaganti's avatar Deepak Penaganti Committed by GitHub

Blurstyle for boxshadow v2 (#88697)

parent c8e30bf4
......@@ -36,11 +36,17 @@ class BoxShadow extends ui.Shadow {
Offset offset = Offset.zero,
double blurRadius = 0.0,
this.spreadRadius = 0.0,
this.blurStyle = BlurStyle.normal,
}) : super(color: color, offset: offset, blurRadius: blurRadius);
/// The amount the box should be inflated prior to applying the blur.
final double spreadRadius;
/// The [BlurStyle] to use for this shadow.
///
/// Defaults to [BlurStyle.normal].
final BlurStyle blurStyle;
/// Create the [Paint] object that corresponds to this shadow description.
///
/// The [offset] and [spreadRadius] are not represented in the [Paint] object.
......@@ -51,7 +57,7 @@ class BoxShadow extends ui.Shadow {
Paint toPaint() {
final Paint result = Paint()
..color = color
..maskFilter = MaskFilter.blur(BlurStyle.normal, blurSigma);
..maskFilter = MaskFilter.blur(blurStyle, blurSigma);
assert(() {
if (debugDisableShadows)
result.maskFilter = null;
......@@ -68,6 +74,7 @@ class BoxShadow extends ui.Shadow {
offset: offset * factor,
blurRadius: blurRadius * factor,
spreadRadius: spreadRadius * factor,
blurStyle: blurStyle,
);
}
......@@ -91,6 +98,7 @@ class BoxShadow extends ui.Shadow {
offset: Offset.lerp(a.offset, b.offset, t)!,
blurRadius: ui.lerpDouble(a.blurRadius, b.blurRadius, t)!,
spreadRadius: ui.lerpDouble(a.spreadRadius, b.spreadRadius, t)!,
blurStyle: a.blurStyle == BlurStyle.normal ? b.blurStyle : a.blurStyle,
);
}
......@@ -123,12 +131,13 @@ class BoxShadow extends ui.Shadow {
&& other.color == color
&& other.offset == offset
&& other.blurRadius == blurRadius
&& other.spreadRadius == spreadRadius;
&& other.spreadRadius == spreadRadius
&& other.blurStyle == blurStyle;
}
@override
int get hashCode => hashValues(color, offset, blurRadius, spreadRadius);
int get hashCode => hashValues(color, offset, blurRadius, spreadRadius, blurStyle);
@override
String toString() => 'BoxShadow($color, $offset, ${debugFormatDouble(blurRadius)}, ${debugFormatDouble(spreadRadius)})';
String toString() => 'BoxShadow($color, $offset, ${debugFormatDouble(blurRadius)}, ${debugFormatDouble(spreadRadius)}), $blurStyle';
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment