Search code examples
fluttergradient

Sharp end on Sweep Gradient


enter image description here

In the above image the red colour has sharp end, how to make it smooth like the other colours.

0.1666666666666667 is average stop for every colour

Container(
      decoration: BoxDecoration(
        color: Colors.red,
        gradient: SweepGradient(
          colors: [
            Colors.purple,
            Colors.indigo,
            Colors.blue,
            Colors.green,
            Colors.yellow,
            Colors.orange,
            Colors.red
          ],
          stops: [
            0.0,
            0.1666666666666667,
            0.1666666666666667 * 2,
            0.1666666666666667 * 3,
            0.1666666666666667 * 4,
            0.1666666666666667 * 5,
            0.1666666666666667 * 6,
          ],
        ),
      ),
      child: Scaffold(),
);

Solution

  • You should add the first color again at last.

    If your first color is purple. So, add purple again at last

              colors: [
                Colors.purple,
                Colors.indigo,
                Colors.blue,
                Colors.green,
                Colors.yellow,
                Colors.orange,
                Colors.red,
                Colors.purple,
              ],