Saving Data in Flutter

Jan 31 2024 · Dart 3, Flutter 3.10, Visual Studio Code

Part 1: Store Data with Flutter

03. Challenge: Choose the Right Storage Solution

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 02. Choosing a Storage Tool Next episode: 04. Using SharedPreferences

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Transcript: 03. Challenge: Choose the Right Storage Solution

This is the first challenge for this course. You’ll see three real-world scenarios for a Flutter app. For each scenario, choose the most suitable local storage solution (among SharedPreferences, Secure Storage, the file system, SQLite, or Hive, based on the requirements.

Consider factors like the size and complexity of the data, the security requirements, and the target of the app. Each scenario requires at least one option but may also require more than one.

For each scenario, write down your chosen local storage solution, and explain why you believe it’s the best fit for the scenario.

First, I’ll show you the three scenarios, and then I’ll ask you to stop the clip.

For each scenario, write down your chosen local storage solution, and explain why you believe it’s the best fit for the scenario.

After you complete your answers, restart the clip, and I’ll give you all the suggested solutions. Ready? Let’s go!

You’re building a note-taking app where users can store confidential information. Each user can set a password to secure their notes. The notes don’t need to be searchable, and they don’t need to sync across devices.

You’re developing a meditation app. It doesn’t need to sync across devices, but it should store the user’s settings, like meditation style, duration, sounds, and reminders. For each completed meditation, the session data will be sent to a web server. There is no need to store the session data in the device.

You’re creating an app for a clinic, where doctors can store patient records. Each record contains information, like patient name, date of birth, medical history, prescription details, and notes. The records need to be searchable and sortable by different fields.

The note-taking app stores sensitive information like passwords and the expected amount of data for an app like this is relatively small.
Flutter Secure Storage is probably the best fit here because it provides encryption out of the box, keeping the user’s confidential data safe.

For the meditation app, the settings data is relatively simple and small, so SharedPreferences would be a good choice here, as it’s ideal for storing small, simple pieces of data, like this.

The clinic app has complex data, and the amount of data is potentially rather large. At the same time it contains sensitive data that needs to be secure.
Here a combination of SQLite and SecureStorage would probably be a good solution.
SQLite can handle the bulk of data, and support searching and sorting, while SecureStorage could be used to anonymize sensitive user information.

Please note that in many cases there might be more than one “right” solution for a project, depending on factors that are not included in these scenarios.
So, well done! Let’s start writing some code with SharedPreferences next!