这里我一一存储了值。API 有 100 万条数据。响应时间为 3 秒 存储缓存需要很多时间。
如何像选择插入查询一样添加所有数据?
storeDefCatMaster(String url,String token) async {
final response = await http.get(
'${url}/v1.0/DefCatMaster',
headers: {'Authorization': 'Bearer ${token}'},
);
final jsonResponse = json.decode(response.body);
DefCatMaster model = DefCatMaster.fromJson(jsonResponse);
int length = model.data.length;
for(int i=0; i<length; i++) {
var data = DataDefCatMaster(
deF_CAT_ID: model.data[i].deF_CAT_ID,
description: model.data[i].description,
in_use: model.data[i].in_use,
sortOrder: model.data[i].sortOrder
);
await helper.insert(data);
}
}