Flutter is currently one of the most popular frameworks available on the market. It allows us to create mobile, web, desktop, and embedded apps from a single codebase, so it’s hardly surprising that it is chosen so frequently. Needless to say, if you’re planning to build a cross-platform app, then Flutter should be one of your go-to choices.
In this article, we want to put the focus on our favourite Flutter tools that we use internally at our Flutter development company. They are stable, well documented, and easy to implement – check them out for yourself!
Best tools for Flutter app development
A powerful HTTP client for Dart that supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout, and much more.
It’s worth mentioning that Flutter itself offers its http package. However, it is more suitable for simple network tasks. In the case of advanced functions, it is much more daunting to use.
- Provides an intuitive API for easily performing advanced networking tasks.
- Offers integration with many additional libraries e.g. retrofit, pretty-dio-logger.
- Allows us to easily add interceptors to handling requests and errors (i.e refreshing JWT tokens).
- Makes it easier to handle multiple simultaneous network requests with the safety and error handling
- Significantly reduces the boilerplate code while simplifying and clearing it.
Hive is a lightweight and very fast key-value database, written in pure Dart. It is worth mentioning that it was created especially for Flutter.
The right choice of a local database has a huge impact on an application – its performance, ease of maintenance, the amount of time that we spent on app creation, and many other factors. That is why I highly recommend you to choose Hive for your project.
- Offers cross-platform support (mobile, desktop, and browser).
- Provides many built-in functions (e.g. strong encryption),
- It has great performance – check this article to learn more.
- Can be used as a substitute for Shared Preferences. In which case we end up depending just on Hive instead of Hive and Shared Preferences.
- Provides support for multiple types (not only the basic ones but also DateTime, Uint8List and List and Map of any primitive types).
- Has a simple, powerful, and intuitive API.
- Hive is one of the most popular libraries, and it is characterized by stability, maturity, and battle-tested.
A state management library that helps implement the BLoC (Business Logic Component) quickly and enjoyably.
What exactly is Flutter BLoC? It is a design pattern that helps separate the presentation layer from the business logic layer. Thanks to this, maintaining, testing, and reusing code is much easier.
We’re proud to say that Miquido, is one of the main sponsors of this awesome library!
- Allows us to decompose the state of an application into smaller, well-defined state machines that transform events into states.
- Represents a reactive approach. So you can say goodbye to maintaining complex subscriptions and lifecycles.
- Provides us with a lot of tools that are connected to each other. You can find them under this link.
- A good example is the bloc_test utility library which simplifies testing of reactive code.
- It has detailed documentation and high-quality tutorials at various levels of advancement.
This is a simple Service Locator for Dart and Flutter projects with some additional goodies.
A Service Locator allows us to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in our app.
As our application grows, we will have to isolate widgets from direct dependencies on classes from the logic layer. This will keep our code more organized and easier to test and maintain.
- It is extremely fast – asymptotic notation O(1).
- It is also very easy to learn and use.
- Supports hierarchical scoping of registration.
- It is a pure Dart dependency injection tool completely independent from UI or Flutter SDK.
- GetIt is very popular and stable.
- Helps to implement Dependency Inversion Principle from SOLID.
Freezed is designed as a language patch, relying on code-generation to implement features that are missing in Dart.
What features am I talking about? If you know any other programming languages such as Kotlin, you may have heard of mechanisms like data class or sealed class. Thanks to them, the code becomes more reliable, readable and simpler. These are some of the many things that Freezed generates.
- Offers a simple and concise model definition. We just need to define the constructor. We can forget about defining property separately.
- Provides support for both data and sealed classes.
- Implements the ‘==’ operator, hashCode, and toString methods, which respectively compares/shows all properties of the object.
- Provides JSON handling. Although Freezed will not generate the typical fromJson and toJson methods on its own, it recognizes the json_serializable library and ensures full compatibility with it
- Freezed has built-in the copyWith with many other methods such as: when, maybeWhen, map, maybeMap.
A Dart package that helps to implement value-based equality without needing to explicitly override ‘==’ and hashCode.
The classic process of comparing objects in Dart is ineffective, boring, and generates lots of boilerplate code. That’s why the Equatable package was created.
- Supports the implementation of the ‘==’ operator, hashCode and toString methods
- Allows us to create a class whose properties don’t change. On the other hand, it’s giving us a method called ‘props’, that returns a list with the chosen properties from the class
Which package should you choose? Freezed or Equatable?
It is a matter of personal preference since the result is very similar. However, it is worth remembering that both tools have a different scope of operations.
Equatable is an abstract class that offers value-based equality with no code generation. On the other hand, Freezed is a code generator that uses annotations to build data/sealed classes. Thanks to it you’ll get automatically generated value-based equality, a lot of functionalities such as copyWith, and JSON serialization support in one place.
It all depends on the case you are considering.
7. Flutter Lints
The Lint system is a static analyzer for identifying possible problems in your source code.
Flutter lint contains a recommended set of lints for Flutter apps, packages, and plugins to encourage good coding practices. It was built on top of Dart’s set of lints from package: lints.
There are over a hundred linter rules available to check for anything from potential typing problems, coding style, and formatting.
- Enforces you to write code using a single, idiomatic style and format.
- Helps to identify common errors, such as dangerous data type combinations.
- Checks many things, including syntax errors and structural problems.
Flutter is a framework that is growing very quickly, which is one of the reasons why many libraries are still appearing on the market.
Unfortunately, many of them will soon become deprecated. Why? They have poor support, tough documentation, or not enough people use them. That’s why you should always use libraries that have good support and are used by big players. Those mentioned in our article fit all the criteria, and they’ve proven to be excellent tools for our Flutter projects. Make sure to try them out!
- Hive’s official documentation
- Dio’s official documentation
- Bloc’s official documentation
- GetIt’s official documentation
- Freezed’s official documentation
- Equatable’s official documentation
- Flutter Lints’s official documentation
Check the author’s website here.