E/flutter (21169): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: type 'List' is not a subtype of type 'List' in type cast
type of getPatientDataList() is Future<List<List<dynamic>> Function() . and I want to create a List<List<<double>>>. But all time failed.
getPatientDataList().then((result) {
dataSize = result.length;
List<List<double>> list = (result.getRange(0, 500).toList()).cast<List<List<double>>>();
print("data " list.toString());
});
CodePudding user response:
try using
getPatientDataList().then((result) {
dataSize = result.length;
List<dynamic> list = (result.getRange(0, 500).toList()).cast<List<double>();
print("data " list.toString());
});
CodePudding user response:
You can do it like
You can use result.sublist
here and wrap with list.
getPatientDataList().then((result) {
final dataSize = result.length;
List<List<double>> list = [
result.sublist(0, dataSize < 500 ? dataSize : 500).toList()
];
});