linearGradient function

LinearGradient linearGradient(
  1. Object? angleOrEndAlignment,
  2. List<String>? colorStopList
)

Create linear gradients with CSS-like coding. For example, the following code.

BoxDecoration(
  gradient: linearGradient(-225, ['#69EACB', '#EACCF8 48%', "#6654F1"]),
);

The angleOrEndAlignment argument is valid only for the double or Alignment type.

The colorStopList argument is a space-separated list of String containing colors and stops. The colorStopList argument must not be null. Colors allow web color names or color codes that start with "#". Stops allow percentage strings like "12.34%".

Implementation

LinearGradient linearGradient(
  Object? angleOrEndAlignment,
  List<String>? colorStopList,
) {
  final endAlignment = _getEndAlignment(angleOrEndAlignment);
  final colorsAndStops = _getColorsAndStops(colorStopList);

  return LinearGradient(
    begin: -endAlignment,
    end: endAlignment,
    colors: colorsAndStops.item1,
    stops: colorsAndStops.item2,
  );
}