Flutter: Performance analysis of `const` constructor

Crizant Lai
Nerd For Tech
3 min readMar 2, 2020

--

Everyone says using const constructors improves the performance of your app, but how much? I haven’t found any analysis on the internet, so I decide to do it myself.

Here is my app for the test:

An app display a random moving Flutter logo

Method

During the test i will create two screens to display the moving logo, one of them uses the const constructor of Image widget:

const Image(
width: 100,
height: 100,
image: AssetImage('assets/logo.png'),
)

And the other one without the const keyword.

The logo is wrapped inside a AnimatedPositioned widget, and its position is updated once per second.

Then we run the app by using the --profile flag, and inspect the “performance” and “memory” tab in Dart DevTools.

Performance overlay of Flutter

In each round of the test, I will increase the number of logos in the screen, to study the performance difference with or without using the const constructor.

--

--

Crizant Lai
Nerd For Tech

A JavaScript/Node/Flutter developer who love technical stuffs.