Try to search your question here, if you can't find : Ask Any Question Now ?

How to fetch all data once without for-loop?

HomeCategory: stackoverflowHow to fetch all data once without for-loop?
julie asked 2 weeks ago

in here I stored one by one value. API has 1 million data. Response time is 3 seconds but storing cache so much time. How to add all data once like select insert query.

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);
  }
}
1 Answers
Best Answer
Arben answered 2 weeks ago
Your Answer

4 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com