Colour.fromFraction constructor

Colour.fromFraction({
  1. double alpha = 1.0,
  2. double red = 1.0,
  3. double green = 1.0,
  4. double blue = 1.0,
})

Creates a colour from channel values between 0.0 and 1.0, the way Flutter stores them.

Every channel defaults to 1.0, so leaving them all out gives opaque white. Values outside the range are clamped.

Implementation

Colour.fromFraction({
  double alpha = 1.0,
  double red = 1.0,
  double green = 1.0,
  double blue = 1.0,
}) : alpha = Radix.fractionToColourValue(alpha.clamp(0.0, 1.0)),
     red = Radix.fractionToColourValue(red.clamp(0.0, 1.0)),
     green = Radix.fractionToColourValue(green.clamp(0.0, 1.0)),
     blue = Radix.fractionToColourValue(blue.clamp(0.0, 1.0));