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?
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.
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.
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.
If you want to set a constant color you can use :
CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.white), )
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With