DEV Community

Cover image for Flutter Databases: 2023 review
ObjectBox.io for ObjectBox

Posted on

Flutter Databases: 2023 review

As Flutter is regarded as one of the most loved mobile frameworks of 2022, the Flutter database scene is thriving too. With an ever-growing market that does not seem to be slowing down, it might be difficult to decide on what database you should use. You can find anything you want from packages that provide plugins to familiar relational databases (Sqflite), to light-weight and high-performance NoSQL databases (ObjectBox).

What should you consider when choosing a Flutter database?

There are a number of factors that you should keep in mind when selecting a database for your flutter project. Although what factors are important to you might differ depending on your particular project, there are a few indicators that are invaluable no matter the app you are building.

  • Speed: Performance is a crucial factor when selecting a database. It not only makes sure you have data when you need it, it saves costs and avoids downtime. For example, a strong response rate on a website can go as far as sales: 70% of respondents in a study noting that page speed impacts their willingness to buy from an online retailer.
  • Ease-of-use: With constant pressure to deliver new apps and / or features, most developers care a lot about the eas-of-use. Depending on your skills or the team’s skill set, choosing a database that comes with native-language APIs that are intuitive to use, will save you a lot of time and nerves short-and longterm. While SQL is still a popular language, it is an additional skill needed, and inot a great match for object-oriented code.
  • Scalability: Even though a project may not have a lot of requirements at the moment, it can grow quickly. Having a database that ensures a capacity to grow with your data and user base can be vital to ensure long-term success.
  • Data Sync: Local databases are great, but sometimes you need your data to sync between systems that are far from each other. You also need to automate an update process that maintains consistency in order to meet your business needs. Almost every mobile application will need data synchronization, but it takes a lot of time as well as introduces a lot of risk. A database that comes with a Sync solution out of the box is a no-brainer in this regard.

{Aside: a word about data sync}

If data-synchronization is your priority, ObjectBox Sync is a next-gen solution equipped to manage data flows and harmonize data across devices, offline as well as online. Discover the easy to use alternative for syncing data – and simply rely on the data being available where you need it when you need it. Sync is a transactionally safe way of making the data sets you select reliably available in a highly efficient way.

What kind of databases exist?

Databases can be classified into various types. The most significant differentiations for our purposes include non-relational (NoSQL) versus relational (SQL) databases, cloud databases versus edge databases, and embedded versus in-memory databases. However, databases can also be distinguished based on additional criteria such as supported data types and scalability, although definitions may vary.

Is an ORM a database?

An Object Relational Mapper (ORM) is not a database itself but rather a layer that sits on top of a database, simplifying its usage. This is particularly relevant when working with relational databases (SQL) and object-oriented programming languages like Dart. It helps bridge the gap between the object-oriented nature of the programming language and the relational structure of the database.

Flutter database landscape in 2023

Let's introduce the key players in the current Flutter database market:

  • Sqflite serves as a wrapper around SQLite, a relational database that lacks direct support for Dart objects.
  • Drift (formerly known as Moor) is an ORM built on top of SQLite, which itself is a well-established lightweight relational (SQL) database.
  • Floor is another ORM that utilizes SQLite as its underlying database.
  • Isar is a fast and lightweight NoSQL database developed by the author of Hive.
  • Sembast is a NoSQL database.
  • Realm is a lightweight NoSQL database primarily written in Java, which was acquired by Mongo DB in 2019.
  • ObjectBox is a highly performant lightweight NoSQL database with integrated data synchronization capabilities.

Note: Since Hive is expected to be deprecated according to its author, we will focus on Isar as the recommended alternative in this discussion.

Package name Package Description Data Model Data Sync Language
sqflite SQLite plugin for Flutter relational SQL
Drift ORM on top of SQLite relational SQL
Floor ORM on top of SQLite relational SQL
Isar Lightweight NoSQL database NoSQL Dart
Sembast NoSQL database, fully document-based NoSQL Dart
Realm NoSQL database NoSQL Yes, but MongoDB Atlas and Cloud are needed Dart
ObjectBox Lightweight NoSQL database + Sync NoSQL Dart

How to choose the best Flutter database?

In conclusion, the Flutter database market is a dynamic and evolving landscape, with new options continually emerging. Choosing the best database option for a Flutter project requires careful consideration of specific project requirements and objectives. In this article, we have reviewed the top options currently available so that you can have a handy reference to the most important tech features. We encourage you to stay informed and check for updates on pub.dev, as well as contribute to the community.

Top comments (0)