Does using const in the widget tree improve performance?

It is a small performance improvement, but it can add up in larger apps or apps where the view is rebuilt often for example because of animations.
const reduces the required work for the Garbage Collector.

You can enable some linter rules in analysis_options.yaml that tell you when you should add const because it’s not inferred but would be possible like

or that reminds you when you use const but it is inferred anyway

See also https://www.dartlang.org/guides/language/analysis-options

Leave a Comment