Why use "const" in your flutter code ?

Why use "const" in your flutter code?

Why add const in your flutter app?

After you read this article you will be eager to use CONST in every way you can in your Flutter code, and you won't be bothered to use it after today in your code.

This is not an article, it is just a snippet or like Tiktok view, short but useful :)

When you build ListView on your flutter widget tree, you may give the list view padding,

And android studio recommends to you use const on this padding, you should add it, why?


Because when you mark this padding as const, this means that this padding won’t run or compiled when build function rebuild, and this is very useful to same some performance in a small app, But Imagine if you working on a huge app and has a lot of Text() widgets, and padding, etc…

Then you will save a lot of performance for your app, and your app will be smooth, and fast and will give the impression of professionalism to your app.

So, if the android studio offers you to use const, don’t ignore that ever anymore.

Follow me on LinkedIn for more of these tips in Flutter




⭐⭐⭐  Buy Food for my Dog 🐶 ⭐⭐⭐

https://buymeacoffee.com/ramy.dmk



Tags

#buttons=(Accept !) #days=(14)

Our website uses cookies to enhance your experience. Learn More
Accept !