Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 类型';列表<;动态>';不是类型为';列表<;MyData>';,颤振_List_Flutter_Dynamic_Casting - Fatal编程技术网

List 类型';列表<;动态>';不是类型为';列表<;MyData>';,颤振

List 类型';列表<;动态>';不是类型为';列表<;MyData>';,颤振,list,flutter,dynamic,casting,List,Flutter,Dynamic,Casting,在flatter小部件中,我将MyData类型的对象列表与Hive包一起存储在内存中 但是当Hive返回数据时,它会在列表中返回数据,我想将其转换为列表,但这样做会产生以下错误 E/flutter (22594): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<MyData>' E/

在flatter小部件中,我将
MyData
类型的对象列表与Hive包一起存储在内存中

但是当Hive返回数据时,它会在
列表中返回数据,我想将其转换为
列表,但这样做会产生以下错误

E/flutter (22594): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<MyData>'
E/flatter(22594):[错误:flatter/lib/ui/ui\u dart\u state.cc(157)]未处理的异常:类型“List”不是类型“List”的子类型
代码:

List data=(monthBox.get(DateTime.now().day).toList()作为列表);
我们可以将
List
转换为
List
而不进行迭代吗

List<MyData> data = (monthBox.get(DateTime.now().day).toList() as List<MyData>);