Storing list of objects in Flutter

做~自己de王妃 提交于 2021-02-11 04:51:33

问题


I am making an app, which contains two basic classes let's say Class1 and Class2. And in Class1 I stored List<Class2> as attribute with other attributes. My question is how to store List<Class2> if I store some object of Class1 in sqflite database. Is there a way that I can store a List of Class2 objects in a single column of the database.


回答1:


You can serialize it to json and save the string. Then when you read it you can parse it back to an Object



来源:https://stackoverflow.com/questions/60267429/storing-list-of-objects-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!