6 small things that let you become a better Flutter developer

Image for post
Image for post

Widgets, widgets, widgets!

You may have probably heard that Flutter is all about widgets. Widgets here, widgets there, and so on. My first piece of advice is this:

Reduce your UI elements to as many small widgets as possible.

Let me elaborate. The two common scenarios we’d like to prevent are as follows:

  1. A huge widget class with lots of build methods (better than the previous option, but still not ideal)
  • Generally creating more widgets goes in hand with the concept of increasing reusability of your code. That way you can easily change a common aspect of your app by simply modifying one widget instead of needing to change hundreds of methods each in separate classes.

If statements

Another small optimization concerns if statements in your Flutter code. Did you know you can use them in your build methods by placing them directly in children lists like this?

Throw in some errors

Some programmers are afraid of girls and some are of throwing errors in their code. Let’s focus on the latter. While developing your app you will sometimes find pathways the code could execute that have no current implementation. In that case, you should throw an error like UnimplementedError in the case a feature is not yet implemented or an UnsupportedError if the given operation is invalid.

const constructors

You should use const constructors wherever possible. Why? Well.. to put it simply, it helps increase Flutter performance by telling which elements won’t change, which means Flutter doesn’t need to rebuild them.

Lint rules

Another useful tool is using a lint package for your project. If you’re not familiar with lint, it’s just an automatic tool that analyzes source code to flag common programming errors, bugs, or stylistic mistakes. To include it in our flutter project we start by adding two packages to our pubspec.yaml file:

  • lint — contains community picked lint rules.

@required & assert

Let’s start off with an example of a constructor for a Product class which will illustrate what you should avoid while defining constructors and methods:


I hope you found at least one of the things we’ve shared as valuable. Some of the tips might seem to be petty, but in reality, a developer’s skill set is a combination of different small details that come together to form his overall competence level.

Flutter and iOS Developer

Sign up for Deviniti Technology-Driven Newsletter

By Deviniti Technology-Driven Blog

Want to join us on the journey through the universe of digital transformation? Sign up to get all the new articles straight to your inbox. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Deviniti is your guide to the universe of digital transformation and enterprise software. On this blog, we share our technical know-how and the latest software development trends we learn.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store