0

how to accommodate an input into a list array with shared preferences?

I made a code like below

handlesave() async {
      SharedPreferences ref = await SharedPreferences.getInstance();
      List<String> _arr = [];

      var idU = user.user.id;
      final dataJ = JobStorageModel(
        iduser: idU.toString(),
        id: widget.job.id,
        job_title: widget.job.job_title,
        location: widget.job.location,
      );
      String json = jsonEncode(dataJ);
      print('save -> $json');
      ref.setString('bookmark', json);
}

so that it becomes a list array like the following

{
  "ID": 1,
  "iduser": "1",
  "job_title": "Designer",
  "location": "monggola"
},
{
  "ID": 2,
  "iduser": "1",
  "job_title": "UX",
  "location": "singapore"
}
Jon
  • 109
  • 2
  • 10

0 Answers0