Flutter is becoming a serious developer platform and with it grows a need for Flutter databases. A quick note on Flutter and Dart as it is pretty young and you might either be looking for a Flutter database, a Dart database or truly a Flutter Dart database. Flutter is an open-source UI software development kit created by Google. Dart is the programming language in which developers code Flutter apps. Dart is an object-oriented programming language.
- The only extension needed for Flutter is called “Flutter”. You can install it by opening Visual Studio Code and pressing on the cog in the bottom left of the screeen and selecting “Extensions”. Type “Flutter” in the Search Box and select the result by the author “Dart Code” (it should be the first result).
- Homebrew’s package index. Name: Flutter SDK UI toolkit for building applications for mobile, web and desktop.
While the database market is huge and dynamic, there are only few options to choose from if you are a Flutter / Dart app developer. Before we dive into the Flutter database options, advantages and disadvantages, we’re taking a very quick look at databases to make sure, we share a common ground. Accordingly, we’ll not get theoretical and extensive, but focus on what we mean here.
Update your path, and run flutter doctor.That will let you know if there are other dependencies you need to install to use Flutter (e.g. The Android SDK). If you did not use the archive, Flutter will download necessary development binaries as they are needed (if you used the archive, they are included in the download). Latest course update now includes an entire module on Flutter State Management! Welcome to the Complete Flutter App Development Bootcamp with Dart - created in collaboration with the Google Flutter team. Covering all the fundamental concepts for Flutter development, this is the most comprehensive Flutter course available online. Brew install flutter brew cask install android-studio When installing Android Studio on macOS you may need to allow system software from “Intel Corporation Apps” and agree to Android licenses. This tutorial was verified with Flutter v1.22.2, Android SDK v30.0.2, and Android Studio v4.1. Setting Up the Project.
What is a database?
A database is a piece of software that allows the storage and systematic use of digital information, in other words: data persistence. A database typically allows developers to store, access, search, update, query, and otherwise manipulate data in the database via a developer language or API. These types of operations are done within an application, in the background, typically hidden from end users. Many applications need a database as part of their technology stack. The most typical database operations are CRUD: Create, Read, Update, Delete.
What are the major types of databases?
There are many types of databases. For our purpose, the most important differentiations are non-relational (NoSQL) versus relational databases (SQL), cloud databases versus edge databases, and maybe embedded versus in-memory. However, databases can be further distinguished by additional criteria e.g. the data types they support, or the way they scale – and definitions can vary.
What is an ORM?
An Object relational Mapper (ORM) is not a database. We’re bringing this up mainly, because we see it confused often. It is a layer that sits on top of a database and makes it easier to use. This is typically especially relevant when the database is a relational database (SQL) and the programming language used is object-oriented. As noted above, Dart is an object-oriuented programming language.
At this point in time, the database landscape for Flutter Dart is still very limited. So, let us quickly introduce the current market players. Note: We are adding in Moor, because with that few player it is just one more option available and therefore, at this moment in time, should be part of the Flutter Dart data persistence landscapes, in our minds.
- Firebase Realtime DBis a cloud-hosted database. It stores data as JSON and synchronizes it to connected clients.
- Hive is a lightweight key-value database written in Dart for Flutter applications, inspired by Bitcask.
- ObjectBox DB is a highly performant lightweight NoSQL database. It stores objects.
- sqflite is a wrapper around SQLite, which is a relational database without direct support for Dart objects.
- Moor is a reactive persistence library for Flutter and Dart, built ontop of sqlite.
Brew Flutter Recipe
Brew Install Flutter
This of course depends… Make up your own mind with the following comparison matrix as a starting point. Note: With very few options to choose from, the following overview is sometimes a bit comparing apples🍎 and pears🍐.
Data persistence | Description | Primary Model | Location of data | Language | License | Fun Fact |
Firebase Realtime Database | Mobile Backend as a Service (MBaaS) | NoSQL | Google Cloud | Dart | Proprietary | acquired by Google in 2014 |
hive | Light key-value DB for Flutter | NoSQL | local | Dart | Apache 2.0 | Munich brew |
ObjectBox | High-performance Flutter DB | NoSQL | local, self-hosted server / cloud | Dart | Bindings are Apache 2.0 | Munich-brew out-of-the-box data sync solution |
sqflite | SQLite plugin for Flutter | relational | local | SQL | SQLite is public domain, sqflite lib is MIT | good old SQLite |
Moor | ORM for SQLite | used on top of a relational DB | local | Dart | SQLite is public domain, Moor lib is MIT | Room spelled backwards |