Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the animation color of a LinearProgressIndicator?

Tags:

flutter

The LinearProgressIndicator documentation helpfully displays the existence of a valueColor property and even mentions "To specify a constant color use: new AlwaysStoppedAnimation(color).", but if I try to set the color I get an error that LinearProgressIndicator has no instance setter for valueColor and the constructor for the class only accepts a key and a numerical value for the progress amount.

If I want a LinearProgressIndicator with a custom color do I need to create my own class? Is there really no way to specify this?

like image 766
Reagankm Avatar asked Dec 09 '16 20:12

Reagankm


People also ask

How do you animate a color change in flutter?

You can animate color of a widget using ColorTween. In the following example, we shall animate color of a button, when it is pressed. When you run this application, and click on the big square button which is colored indigo, animation of color starts and changes the color of button to limegreen.

How do I change the color of my circular progress indicator in flutter?

Step 1: Locate the CircularProgressIndicator of which you would like to change the color. Step 2: Add the valueColor property. Step 3: Assign the AlwaysStoppedAnimation() . Step 4: Inside the AlwaysStoppedAnimation(), add the color of your choice.

How do you use linear progress indicator in flutter?

LinearProgressIndicator. The linear progress bar is used to show the progress of the task in a horizontal line. Flutter provides mainly two types of linear progress indicators: Determinate: Determinate progress bar indicates the actual amount of progress at each point in making the task.


2 Answers

If you want to set a constant color you can use :

CircularProgressIndicator(   valueColor: AlwaysStoppedAnimation<Color>(Colors.white), ) 
like image 163
toregua Avatar answered Sep 25 '22 12:09

toregua


Looks like it's controlled from the Theme's accent color: https://github.com/flutter/flutter/blob/b670ce4bcc49bbab745221eae24fcebcbc9dba7c/packages/flutter/lib/src/material/progress_indicator.dart#L61

Wrap the relevant subtree in a modified Theme setting the accentColor to whatever you might like.

like image 45
Eric Seidel Avatar answered Sep 21 '22 12:09

Eric Seidel