How to write Flutter code efficiently

Tanmoy karmakar
GYTWorkz
Published in
3 min readJul 2, 2022

When we start with any development we generally tend to write each code manually. That is good no doubt but once we are well versed with that technology, if we still follow that same rule it might hamper our code writing skill and take much longer time to complete your work.

I am a very lazy coder 😂

Lets me tell this thing first. I always like automate my work and try to write minimum code.

In this blog, I will list down all my settings in VsCode and all the code generation methods that I use to make my flutter development ease.

Extensions

Lets start with Vscode extensions

  1. GitHub Copilot

The moment I got my hands on the early access of copilot my code generally writes itself even before i write a word. It can easily predict from my previous code and also from the comments I write to generate the code.

2. Awesome Flutter Snippets

This extension has all the basic snippets needed for normal usage such as stateful and stateless widget and other defined widgets.

3. bloc

The most easy way to create a freezed compatible bloc snippet.

4. Thunder Client

I dont like to open any other applications like post man to check api response instead, I directly do it from my vscode using the thunder client.

5. Pubspec Assist

How many times we need to open the pubspec.yaml file and add one dependency at a time. I can easy count 20–30 times. but this extension helps me add packages from anywhere. check out the usage.

Code Generator

Here are the cli and packages I use for code generation.

  1. Very good CLI

The ease of creating project with all required flavors and native splash is just great. I love the work of Felix Angelov and Very good ventures. Just check out how easily you can start your project with least 4–5 hours work already in done state.

2. Mason

Mason is a code generation packages by the same team at Very good ventures. It is the easiest way to create personalized template that can be use anywhere.

Personally I use my own package that i have created which creates complete feature folder with bloc code and it has helped me write code in matter of few seconds.

3. Freezed

Freezed need no introduction. It helps in creating generated file for assets, blocs and models. You need to pair it with few other packages to make it work the best.

Additional packages to complement freezed

Vscode Settings

  1. Fix code on save
"editor.codeActionsOnSave": {"source.fixAll": true},

this fixes all the warnings in my code and makes sure my code does not have any warnings.

2. Organise and remove unused imports

This removes all unused imports and sort them in proper order for easy reading.

This was my list of all extension and settings that I use.

Thanks for reading this article ❤️

I am open to flutter discussion and any questions.

reach me at LinkedIn !!

Support me at,

--

--