Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add linear gradient to LinearProgressIndicator?

How can you add a LinearGradient to a LinearProgressIndicator?

This is what I have now:

LinearProgressIndicator(
 value: 0.3,
 valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
)

Instead of a colour I would like to use a linear gradient. Is it possible?

like image 584
puls99 Avatar asked Dec 30 '25 03:12

puls99


2 Answers

You can use the gradient_widgets package which has a GradientProgressIndicator that is what I belive you're looking for.

Than you can use like so

GradientProgressIndicator(
                  gradient: Gradients.rainbowBlue,
                );
like image 161
Miguel Ruivo Avatar answered Dec 31 '25 18:12

Miguel Ruivo


Instead of a LinearProgressIndicator, you could used a Container with a gradient and fixed height. The width would correspond to the value of the linear progress indicator times the width of the screen, e.g.

    Container(
      width: MediaQuery.of(context).size.width * <value>,
      decoration: BoxDecoration(
        gradient: LinearGradient(
        colors: [
          Colors.red,
          Colors.blue
        ],
        stops: [
          0.1,
          0.5,
        ],
       ),
     ),
     child: SizedBox(
       height: 20.0,
     ),
   ),
like image 26
Lee Mordell Avatar answered Dec 31 '25 18:12

Lee Mordell