如何将数据输入保存到数组?
我有代码,所以我创建了一个存储在存储中的输入,我创建了一个数据提交函数,它是句柄保存,
handlesave() async {
SharedPreferences ref = await SharedPreferences.getInstance();
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);
}
这是我做的模型
class JobStorageModel {
int id;
String iduser;
String job_title;
String location;
JobStorageModel({
this.id,
this.iduser,
// ignore: non_constant_identifier_names
this.job_title,
this.location,
});
JobStorageModel.fromJson(Map<String, dynamic> json) {
this.id = json['ID'];
this.iduser = json['iduser'];
this.job_title = json['job_title'];
this.location = json['location'];
}
Map<String, dynamic> toJson() {
return {
'ID': this.id,
'iduser': this.iduser,
'job_title': this.job_title,
'location': this.location,
};
}
}
如何容纳输入?