Currently if there is a list in db, and I wanna add a new item, I have to use following method:
List<String> contentsList = [];
updateList() async{
contentsList.clear();
ProfilesProvider profilesProvider = ProfilesProvider();
contentsList = await profilesProvider.updateProfileSpeech(profile: profile);
}
So clear the whole contentsList
, which means refresh totally, I guess it is not so efficient, since I just update one Item but have to update whole list, What I thought is not to catch data from db, instead just adding this item to List meanwhile save it into db
updateList2(String newItem) async{
contentsList.add(newItem);
}
But in this way if I edit / delete / add an item I have to create different method and need to know the right index, is there a better solution or thoughts?
I am just learning coding, is it the right way to handle such issue? thanks!