How to save and get a list of lists using Shared preferences in dart/flutter

女生的网名这么多〃 提交于 2021-02-07 21:54:25

问题


I have been trying to save a list of lists using shared preferences in dart. For example, I have a list List data = [["dave","21","M"],["steven","22","F"]] and I am trying to save and load as it is but app keeps throwing Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<String>'

I have tried converting the 2d list into a list using List new_data = data.expand((i) => i).toList(); and then saving it. But still, the exception persists even though it is a list containing only strings.

来源:https://stackoverflow.com/questions/56198413/how-to-save-and-get-a-list-of-lists-using-shared-preferences-in-dart-flutter

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