14

I am still new to the Flutter environment and find it hard to find information about storage options when building an app with Flutter.

Similarly to what has been asked for react native, I would like to know what my options are with respects to

  • Data persistence
  • Remote or locale
  • Offline behavior (if applicable)
  • Database security
  • App performance
  • Pricing
  • Real time sync
  • Compatibility with third party libraries, and Flutter modules
  • Anything else...

I have searched the flutter packages for database but did not find it so helpful. Any answer, guide and reference would be much appreciated.

7hibault
  • 2,371
  • 3
  • 23
  • 33
  • did you try sqlite? – goops17 Jul 10 '18 at 16:51
  • 8
    While the question is well written, it doesn't belong to SO there's no finite answer. This should be more the topic of a medium post or similar. Not a SO question. – Rémi Rousselet Jul 10 '18 at 16:57
  • like react native, you can use firebase. google flutter firebase. – letsCode Jul 10 '18 at 17:20
  • take a look at this [answer](https://stackoverflow.com/questions/41369633/how-can-i-save-to-local-storage-using-flutter/50849802#50849802) – Raouf Rahiche Jul 10 '18 at 18:10
  • Your link is actually quite helpful, perhaps sort the list by score and click thru the top 5. (the sqflite one even has example code) – petey Jul 10 '18 at 19:02
  • @RémiRousselet I hesitated a lot before posting it but what convinced me to do it is that the react native one was not, got a lot of attention (upvotes and bounty to the answer), which means that the community has a clear interest in that question. Now, I do understand your comment in the scope of SO. How would you proceed? Closing now is an option but wouldn't allow the community to benefit from answers – 7hibault Jul 11 '18 at 07:54
  • Yeah I got surprised the RN worked out. There are many similar questions that are closed daily afterall. Maybe you can change the question to a "How to use X in flutter". And possibly other questions such as "what is the difference between X and Y?". – Rémi Rousselet Jul 11 '18 at 08:11
  • 1
    Great question. I am only interested in finding an ORM for flutter as this would solve the database issue. With a funcitoning ORM you would be able to use any database there is. – Roman Gherta Jul 17 '18 at 06:47
  • 2
    I can't downvote a comment so doing it in text - disagree strongly with Rémi Rousselet. I think SO *is* the right place to ask "what are my options". The OP is not asking for a comparative judgement of "best" just a list of what is available now and any hard facts such as performance. – Andy Dent Dec 21 '18 at 03:03
  • you can use, Hive - offline NoSQL storage – A.Mushate Oct 14 '20 at 08:24

4 Answers4

6

I have one opensource project on GitHub make sure to check out -

A flutter project with Implementation of a Contacts app in 4 ways (API, Custom, Preferences and Sqflite).

In this Sample Project, there are 4 ways which I have used to store data in flutter which are as follows -

  1. REST API ->  (You can store your Data on Server and Perform CRUD Operations with REST APIs)
    HTTP Package for REST APIs Integration in Flutter

  2. Preferences ->   (Store your Data in Shared Preferences)
    Shared Preferences Package in Flutter

  3. Sqlite ->   (Store your Data in SQLite Database)
    Sqflite Package in Flutter

  4. Custom ->   (Store your Data in temporary objects but it will only be accessible during app runtime)

Harsh Sharma
  • 898
  • 1
  • 14
  • 30
  • Hi, how can I achieve the fourth point i.e Store your Data in temporary objects but it will only be accessible during app runtime any example? – Vijay Ankith Apr 24 '19 at 08:12
  • @VijayAnkith check the source code of the following repo - https://github.com/harsh159357/contacts – Harsh Sharma Apr 24 '19 at 17:57
  • Rest api. Is it easy to deal with images storing? – Rokas Devolskis Apr 08 '20 at 22:38
  • @RokasDevolskis rest api is the easy way to store images but in my sample project i did it in the BLOB way (In which you can store images directly in the tables in database). But i might suggest you to use some image hosting service for image storing and use that image hosting service image url to be saved in your table – Harsh Sharma Apr 19 '20 at 09:54
0

You can use shared_preferences as an equivalent to React Native Async Storage, you can read more here. sqflite is a good approach for having a local database for offline use. You can use the firebase plugins for online data storage and synchronization.

Rolando Urquiza
  • 1,404
  • 3
  • 17
  • 29
0

To store a large database you can use SQFlite Helper that is explained here.

Sami-L
  • 5,553
  • 18
  • 59
  • 87
Sunil
  • 3,211
  • 3
  • 21
  • 21
0

I used to work on the Realm Xamarin team and am currently using Realm in both a Xamarin Forms app and Swift app, so when I started musing Flutter looked into it.

Realm as of 2018-12 doesn't support Flutter for the same reason that any other C-based data engine will struggle - the problem being poor support in Flutter, as per this issue.

A necessary first step is probably the Dart VM FFI issue.

There's a long issue tracker thread on the request to add this to Realm and forum discussion.

Unsurprisingly, there's currently Firebase and SQLite support.

Andy Dent
  • 17,578
  • 6
  • 88
  • 115