Creating a Custom Lint Package for Better Code Quality in Flutter

Gil Bassi
5 min readJun 12, 2023

Enhancing Code Quality and Maintainability in Flutter Projects with Custom Linting

Photo by Artur Shamsutdinov on Unsplash

Problem

Flutter is awesome and Dart’s static analysis makes it extremely powerful for catching bugs early with its type safety. However, we have all seen a few projects with some code smells that makes maintainability hard, even when you toggle on all important lint rules or use a pre-defined set of rules, like the very_good_analysis package.

One of the most common problems I have seen is logic in the UI, which usually starts with some innocent methods on a widget to switch features on and off, but then it suddenly grows out of proportions. When you see, someone just wrote an entire small application inside that widget and it is all tangled together.

Also, let’s not forget the infamous practice of using strings in conditionals and switch statements instead of enums. Who needs “user.status == ‘active’” repeated throughout the codebase?

Another common problem I see often is the infamous primitive obsession, where developers with a different background are not familiar with Object Oriented Programming start writing complex logic using strings to represent something else.

--

--

Gil Bassi

Software Engineer, Flutter developer and coffee drinker