如何将输入容纳到具有共享首选项的列表数组中?
我做了如下代码
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);
}
使它成为一个列表数组,如下所示
{
"ID": 1,
"iduser": "1",
"job_title": "Designer",
"location": "monggola"
},
{
"ID": 2,
"iduser": "1",
"job_title": "UX",
"location": "singapore"
}