[FIXED] Store data as an object in shared preferences in flutter

Issue

I want to store an object in shared preferences which contains some fields in it like name, age, phone number etc. I don’t know how to store an object in shared preferences in flutter.

Solution

You need to serialize it to JSON before saving and deserialize after reading

See https://flutter.io/docs/development/data-and-backend/json for details

Answered By – Günter Zöchbauer

Answer Checked By – Candace Johnson (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published