areaGradientShader function

Gradient areaGradientShader(
  1. Color color, {
  2. required double top,
  3. required double bottom,
  4. double topAlpha = 0.32,
})

A soft vertical gradient shader fading from color near top to transparent at bottom. Mirrors areaGradient in the Compose library.

Implementation

ui.Gradient areaGradientShader(
  Color color, {
  required double top,
  required double bottom,
  double topAlpha = 0.32,
}) {
  return ui.Gradient.linear(
    Offset(0, top),
    Offset(0, bottom),
    [
      color.withValues(alpha: topAlpha),
      color.withValues(alpha: topAlpha * 0.45),
      color.withValues(alpha: 0),
    ],
    const [0.0, 0.5, 1.0],
  );
}