Ad

How Do I Set The Animation Color Of A LinearProgressIndicator?

- 1 answer

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?

Ad

Answer

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.

Ad
source: stackoverflow.com
Ad