Ephenodrom / Dart-Basic-Utils

A dart package for many helper methods fitting common situations
MIT License
368 stars 79 forks source link

added ColorUtils.lerp(List<Color> colors, double t) function #77

Open xonaman opened 2 years ago

xonaman commented 2 years ago

Similar to Color.lerp, but it supports more than just two colors.

Very useful in my case, so I thought I might as well share it.

Edit: Please add import 'dart:math' as math;, I forgot it

Example usage:

LinearProgressIndicator(
  value: progress,
  color: ColorUtils.lerp([
    Colors.red,
    Colors.yellow,
    Colors.green,
  ], progress),
)
Ephenodrom commented 2 years ago

@xonaman Looks great! Can you please add a unit test ?