Home > Software design >  LinearGradient with multiple stops
LinearGradient with multiple stops

Time:04-21

I am having an idea about drawing a LinearGradient with only 2 colors but with 3 stops, i.e. 2 colors on the 2 sides but the neutral is not in the middle, it can be left or right (stops between 0 -> 1).

I know stops needs to be the same length as colors from enter image description here

CodePudding user response:

Try lerp example https://dartpad.dev/?id=4916732360a976a5e4cb33a915a64c86

colors: [colorLeft, Color.lerp(colorLeft, colorRight,0.25)??colorLeft, colorRight],

Adjust settings to suit your need. Read at https://api.flutter.dev/flutter/dart-ui/Color/lerp.html

  • Related