Speed up writing Flutter Redux code in your IDE

Paulina Szklarska
ITNEXT
Published in
3 min readJul 5, 2021

--

Hi! 👋

If you’re developing your Flutter application using Redux, you know that this architecture has many advantages. Unfortunately, like everything, it also has some drawbacks. One of them is the amount of code you have to write for every new widget that wants to benefit from the Redux Store.

Today I’d like to show you a nice way for speeding up this process. It’ll be useful for you if you’re using Android Studio, IntelliJ IDEA or Visual Studio Code.

Android Studio/IntelliJ IDEA

In this IDE we’re gonna use a feature called Live Template. To create a new Live Template, go to the Settings/Preferences | Editor | Live Templates.

In the editor window, tap on the + icon and add a new Live Template. Fill in the abbreviation you want to use for your template (it’s redux in my case) and the description. Paste the following text in the Template text field.

Under the Template text field, select Define… to choose a context to which template can be applied to and select Dart: top-level.

That’s it! To start using it, open any dart file and start typing redux. That should show your new Redux template.

To read more about Live Templates, visit IntelliJ IDEA documentation

Visual Studio Code

In this IDE we’ll use a feature called Snippets. To create a new Snippet, go to the File/Code | Preferences | User Snippets.

In the window that’ll appear, choose dart. That should open the editor for your snippet. Paste the following code into that editor and save it:

To use it, open one of your dart files and start typing redux. That should highlight your new Snippet:

To read more about Snippets, visit Visual Studio Code documentation

Summary

To summarise, today I showed you how you can use Live Templates or Snippets to speed up your work. You can use them for many other things, including frequently used utility methods or the boilerplate code. Let me know in the comments about your ideas!

--

--

Flutter GDE / Flutter & Android Developer / blogger / speaker / cat owner / travel enthusiast