5 mind-blowing Flutter tips and tricks, that you can use right away!
Today I’m going to present to you 5 extremely useful flutter tips that you can immediately apply to your project. I won’t present you any packages or extensions, but very simple, but extremely useful tips!
This article was created in cooperation with Flutter Mapp. Thank you very much!
Cleaner folder structure
After creating a new flutter project, there are way too many files. But we can structure these files with very simple steps in VSCode:
- Open the command palette (Ctrl/Cmd + Shift + P)
- type “preferences: Open Settings (JSON)”
- add the following lines to your settings.json:
Here is a before and after comparison:
As you can see, many files that we rarely use are now hidden in
pubspec.yaml. Of course you can expand
pubspec.yamland access these files.
Auto Fix linters
It’s very annoying to fix all the linter problems one by one. Even if you use for example the “add const keyword” dialog, doing this every time is in long term very time-consuming. That’s why we will create a way to automatically add these small things when saving a file. To do so, we go back to our settings.json (Instructions in the previous tip) and add the following:
Awesome Flutter Snippets
I know, I know, I’ve said that I won’t add an extension to this tips article, but this extension is a must-have for every Flutter developer. It provides you so many different Flutter snippets that you can use right away to speed up your development. It has 40+ snippets for every use case and supports complex widgets:
Print vs log
Sometimes, if you want to print an error to the console, the error is way too long to be displayed. This is because print has a character limit. To display the error, just use
In the second tip, we have spoken about how to add things like
const keywords automatically. Now we want to format our file as soon as we save it. To do so, add the following line to your settings.json:
Further reading & Conclusion
In this article, you have seen 5 tips that are extremely useful.
Did you know that I have many tips like this? Check them out here.
In the next few articles, I will introduce more great tips & repositories. If you don’t want to miss this, I recommend you to follow me. I tried my best to get the best tips that everyone likes. If you appreciate this work, I would be very grateful if you could support this quality content and give me some claps!