calculateBackground method

Color calculateBackground()

Implementation

Color calculateBackground() {
  if (widget.backgroundColorEnd != null) {
    double percent;

    // calculates the percentage of the position of the slider
    if (_position > widget.width - widget.height) {
      percent = 1.0;
    } else if (_position / (widget.width - widget.height) > 0) {
      percent = _position / (widget.width - widget.height);
    } else {
      percent = 0.0;
    }

    int red = widget.backgroundColorEnd!.red;
    int green = widget.backgroundColorEnd!.green;
    int blue = widget.backgroundColorEnd!.blue;

    return Color.alphaBlend(
        Color.fromRGBO(red, green, blue, percent), widget.backgroundColor);
  } else {
    return widget.backgroundColor;
  }
}