Flutter & Data Storage

Author: COPS SDG Published on: June 15, 2021

Flutter

Asynchronous code in Dart & Flutter

You must have encountered keywords like async, await and Future till now. These are very important blocks that one should comprehend.

Get this concept with this video created by Google developers themselves

Storing data locally

Persisting Key-Value based data using SharedPreferences

There are a lot of options for storing data locally. The most basic one is using the shared_preferences plugin.

Here is a video explaining the shared_preferences plugin

or you can read this tutorial

Store key-value data on disk

Although key-value storage is easy and convenient to use, it has limitations:

  • Only primitive types can be used: int, double, bool, string, and stringList.
  • It’s not designed to store a lot of data.

sqflite plugin overcomes these limitations.

Persist and Query data locally on the device with SQLite.

What is SQLite?

Before moving any forward, you must know what exactly is SQLite. The following tutorial gives you a brief overview of the same.

What is SQLite? Top SQLite Features You Should Know

Creating a local SQLite database using sqflite package Flutter

Here comes the Flutter part.

There are a bunch of packages available to store data locally on the device, but the one recommended by Flutter is the "sqflite" package which is an SQLite plugin for Flutter.

Here is a short video by Flutter team explaining the sqflite package

Now, let's read and learn about the sqflite plugin!

Persist data with SQLite

or if you are more of a video person

The sqflite Alternative

sqflite is all you need for storing structured data locally therefore, explore this section only when you are done with sqflite.

Hive

Hive is a key-value (NoSQL) based database that is much faster than sqflite.

Hive Docs

A beginners tutorial to Hive

Challenge and Submission

This Blog is a part of CSoC'21 Dev Frontend.

Remember, deadline for this task is June 21st, 2021 23:59.

So much for learning, here is your next Assignment

COPS-IITBHU/csoc-2021-task-2

All the details of the task are provided in the README.md file.

Just like last task you have to create your own repo and then make a PR in above repo to add your entry into [Flutter.md](http://flutter.md) with apk link and repo link only