Skip to content

Commit

Permalink
Reformat and fix analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Aug 21, 2023
1 parent 099b64f commit a56e92d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/src/functions/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,9 @@ Value _rgb(String name, List<Value> arguments) {
arguments[1].assertNumber("green"),
arguments[2].assertNumber("blue"),
alpha.andThen((alpha) =>
_percentageOrUnitless(alpha.assertNumber("alpha"), 1, "alpha")
.clamp(0, 1)) ?? 1,
_percentageOrUnitless(alpha.assertNumber("alpha"), 1, "alpha")
.clamp(0, 1)) ??
1,
fromRgbFunction: true);
}

Expand Down Expand Up @@ -959,8 +960,9 @@ Value _hsl(String name, List<Value> arguments) {
arguments[1].assertNumber("saturation"),
arguments[2].assertNumber("lightness"),
alpha.andThen((alpha) =>
_percentageOrUnitless(alpha.assertNumber("alpha"), 1, "alpha")
.clamp(0, 1)) ?? 1);
_percentageOrUnitless(alpha.assertNumber("alpha"), 1, "alpha")
.clamp(0, 1)) ??
1);
}

/// Asserts that [angle] is a number and returns its value in degrees.
Expand Down
13 changes: 9 additions & 4 deletions lib/src/value/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class SassColor extends Value {
///
/// Throws a [RangeError] if [alpha] isn't between `0` and `1`.
factory SassColor.hsl(num? hue, num? saturation, num? lightness,
[num? alpha= 1]) =>
[num? alpha = 1]) =>
SassColor.forSpaceInternal(
ColorSpace.hsl,
_normalizeHue(hue?.toDouble()),
Expand Down Expand Up @@ -388,7 +388,8 @@ class SassColor extends Value {
/// [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
///
/// Throws a [RangeError] if [alpha] isn't between `0` and `1`.
factory SassColor.xyzD50(double? x, double? y, double? z, [double? alpha = 1]) =>
factory SassColor.xyzD50(double? x, double? y, double? z,
[double? alpha = 1]) =>
SassColor.forSpaceInternal(ColorSpace.xyzD50, x, y, z, alpha);

/// Creates a color in [ColorSpace.xyzD65].
Expand All @@ -399,7 +400,8 @@ class SassColor extends Value {
/// [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
///
/// Throws a [RangeError] if [alpha] isn't between `0` and `1`.
factory SassColor.xyzD65(double? x, double? y, double? z, [double? alpha = 1]) =>
factory SassColor.xyzD65(double? x, double? y, double? z,
[double? alpha = 1]) =>
SassColor.forSpaceInternal(ColorSpace.xyzD65, x, y, z, alpha);

/// Creates a color in [ColorSpace.lab].
Expand Down Expand Up @@ -514,7 +516,10 @@ class SassColor extends Value {
SassColor.forSpaceInternal(this._space, this.channel0OrNull,
this.channel1OrNull, this.channel2OrNull, double? alpha,
[this.format])
: _alpha = alpha.andThen((alpha) => fuzzyAssertRange(alpha, 0, 1, "alpha")) {
// TODO(nweiz): Support missing alpha channels.
: _alpha =
alpha.andThen((alpha) => fuzzyAssertRange(alpha, 0, 1, "alpha")) ??
1.0 {
assert(format == null || _space == ColorSpace.rgb);
assert(
!(space == ColorSpace.hsl || space == ColorSpace.hwb) ||
Expand Down

0 comments on commit a56e92d

Please sign in to comment.