LinearGradientDescriptor.random constructor

LinearGradientDescriptor.random()

Implementation

factory LinearGradientDescriptor.random() {
  List<Color> colors = ColorUtils.randomColors(2, 3);
  List<double> stops = <double>[];
  double step = 1 / (colors.length - 1);
  for (int i = 0; i < colors.length; i++) {
    stops.add(i * step);
  }
  List<Alignment> alignments = Alignment.bottomCenter.values;
  Alignment beginAlign = GenericUtils.pickRandom(alignments);
  alignments.remove(beginAlign);
  Alignment endAlign = GenericUtils.pickRandom(alignments);
  return LinearGradientDescriptor(
      colors: colors,
      beginAlign: beginAlign,
      endAlign: endAlign,
      stops: stops);
}