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 { ...@@ -36,11 +36,17 @@ class BoxShadow extends ui.Shadow {
Offset offset = Offset.zero, Offset offset = Offset.zero,
double blurRadius = 0.0, double blurRadius = 0.0,
this.spreadRadius = 0.0, this.spreadRadius = 0.0,
this.blurStyle = BlurStyle.normal,
}) : super(color: color, offset: offset, blurRadius: blurRadius); }) : super(color: color, offset: offset, blurRadius: blurRadius);
/// The amount the box should be inflated prior to applying the blur. /// The amount the box should be inflated prior to applying the blur.
final double spreadRadius; 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. /// Create the [Paint] object that corresponds to this shadow description.
/// ///
/// The [offset] and [spreadRadius] are not represented in the [Paint] object. /// The [offset] and [spreadRadius] are not represented in the [Paint] object.
...@@ -51,7 +57,7 @@ class BoxShadow extends ui.Shadow { ...@@ -51,7 +57,7 @@ class BoxShadow extends ui.Shadow {
Paint toPaint() { Paint toPaint() {
final Paint result = Paint() final Paint result = Paint()
..color = color ..color = color
..maskFilter = MaskFilter.blur(BlurStyle.normal, blurSigma); ..maskFilter = MaskFilter.blur(blurStyle, blurSigma);
assert(() { assert(() {
if (debugDisableShadows) if (debugDisableShadows)
result.maskFilter = null; result.maskFilter = null;
...@@ -68,6 +74,7 @@ class BoxShadow extends ui.Shadow { ...@@ -68,6 +74,7 @@ class BoxShadow extends ui.Shadow {
offset: offset * factor, offset: offset * factor,
blurRadius: blurRadius * factor, blurRadius: blurRadius * factor,
spreadRadius: spreadRadius * factor, spreadRadius: spreadRadius * factor,
blurStyle: blurStyle,
); );
} }
...@@ -91,6 +98,7 @@ class BoxShadow extends ui.Shadow { ...@@ -91,6 +98,7 @@ class BoxShadow extends ui.Shadow {
offset: Offset.lerp(a.offset, b.offset, t)!, offset: Offset.lerp(a.offset, b.offset, t)!,
blurRadius: ui.lerpDouble(a.blurRadius, b.blurRadius, t)!, blurRadius: ui.lerpDouble(a.blurRadius, b.blurRadius, t)!,
spreadRadius: ui.lerpDouble(a.spreadRadius, b.spreadRadius, 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 { ...@@ -123,12 +131,13 @@ class BoxShadow extends ui.Shadow {
&& other.color == color && other.color == color
&& other.offset == offset && other.offset == offset
&& other.blurRadius == blurRadius && other.blurRadius == blurRadius
&& other.spreadRadius == spreadRadius; && other.spreadRadius == spreadRadius
&& other.blurStyle == blurStyle;
} }
@override @override
int get hashCode => hashValues(color, offset, blurRadius, spreadRadius); int get hashCode => hashValues(color, offset, blurRadius, spreadRadius, blurStyle);
@override @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