SharedPreference loses data when updating the flutter app on App Store and Play Store

Viewed 194

I have written a flutter app. The app is using sharedPreferences version 0.5.7 to store data. The issue is when I debug the app on my device, there is no data loss. But when it is published on Play Store and App Store, the consumers complained that when they updated the app their previous data got deleted. Why this might be happening? How to debug or stop this from happening in future?

1 Answers

According to the Flutter Team shared sharedPreferences should not be used for storing critical data.

"One thing to remebmer for sharedPreferences and presistend storage,there is no guarantee that the writes will be persisted to disk , so make sure you do not use it to store any critical data"

2 good alternatives are

  1. Hive NoSQL (https://pub.dev/packages/hive)

  2. SQFlite (https://pub.dev/packages/sqflite)

Related