'How do I set the animation color of a LinearProgressIndicator?

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?



Solution 1:[1]

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.

Solution 2:[2]

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

CircularProgressIndicator(
  valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
)

Solution 3:[3]

LinearProgressIndicator(
    backgroundColor: Color(0xFFB4B4B4),
    valueColor: AlwaysStoppedAnimation<Color>(Colors.green),
)

Solution 4:[4]

I think you can provide in the below way,

LinearProgressIndicator( valueColor: AlwaysStoppedAnimation<Color> (Color(0xFFA86E52)),),

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eric Seidel
Solution 2 iDecode
Solution 3 kalucki23
Solution 4 Dharman