Skip to main content

Linting on Flutter reaches version 3.0

Today I come to talk to you about something that sometimes goes unnoticed but that as a dependency of our Flutter projects, we must take care to keep updated and be aware of the news they present. In this case I'm talking about the flutter_lints dependency which is in charge of the linting of our Flutter projects.

A robot that lists the errors found in unreadable Flutter code.

What is a Linting tool?

Linting is the automated checking of your source code for programmatic and stylistic errors. This is done by using a lint tool (otherwise known as linter) that in this case comes as a dependency and it's called flutter_lints. A lint tool is a basic static code analyzer. If we go to the definition of this package we can read the following:

Basically we can clarify that this, like any other linter, defines a set of rules that must be followed during code analysis. These rules are not strict and can be silenced by creating an analysis_options.yaml file (this can be done in very specific needs where conflicts with some continuous integration tools could occur but it is generally discouraged).

Don't think that just because you have created a new project you are using the latest version of the dependencies as the Flutter project generation template is not exempt from being updated and is not always automatically taken into consideration when updating libraries. This means that if we create a new Flutter project our version of flutter_lints is:

Part of the pubspec.yaml file where the flutter_lints dependency is updated.

The thing is that if we take a look at flutter_lints dependency inside of the repository we can see the following:

Publication of flutter_lints 3.0 in

I'm afraid it's out of our hands to update the Flutter template, but what we can do whether we are creating a new project or working on existing projects is to update the flutter_lints version.

What's in this new version?

If we look at the previous version, this is a major release, which means that it brings with it a handful of interesting changes. To review it, we go to the Changelog of the package and we can see that among its changes, the minimum version of Flutter to support this package has changed to 3.10. On the other hand, the version of Dart has also changed, which will force us to use at least version 3.0.

Changelog with the list of changes in flutter_lints 3.0.0

One important thing. Any of these rules can be copied and googled to get a deep description of each of them. For example, searching in Google simply by the string prefer_equal_for_default_values we get as first result:

Result of a Google search for the flutter linter rule named prefer_equal_for_default_values.

If we click inside we can read a complete description of the rule and even what triggers it (BAD) and what resolves it (GOOD). 

Details of what causes the prefer_equal_for_default_values rule to fire or not.

Easy indeed. Now, we can see two clear lists of rules that have been added and removed. 

What has been removed?

Before we go through the two lists, I suggest that you should be warned that you may not find anything interesting in the removed list as there is nothing to worry about. The removed rules were already deprecated in version 2 of flutter_lints due to restructuring they have done in the parser affecting the following rules.


The linter is a tool that should be mastered in order to have a clean project and will help us to maintain good development practices. So we should have it updated and be aware of their news. 

I hope you liked it and see you in the next post.



© 2020 Mobile Dev Hub