接收类型为"List<系列<动态,动态>>"的运行时错误不是'List< Series< dynamic,num>>'类型的子类型chart_flutter [英] Receiving runtime error with type 'List<Series<dynamic, dynamic>>' is not a subtype of type 'List<Series<dynamic, num>>' charts_flutter
本文介绍了接收类型为"List<系列<动态,动态>>"的运行时错误不是'List< Series< dynamic,num>>'类型的子类型chart_flutter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使 charts_flutter
变得扑朔迷离,并且我已经使用 LineChart
示例进行了修改,以适合我的应用程序.我没有收到任何构建错误,但是,我收到了
I'm trying to get the charts_flutter
for flutter, and I've used the LineChart
example with modifications to fit into my app. I'm not receiving any build errors, however, I'm receiving a run time error of
'List<Series<dynamic, dynamic>>' is not a subtype of type 'List<Series<dynamic, num>>'
这是构建图表的代码
_buildChart() {
if (seriesList == null) {
return Container();
} else {
return new charts.LineChart(seriesList, animate: true);
}
}
我将系列填充为:
setState(() {
seriesList = [
charts.Series<Stat, num>(
id: 'Income',
colorFn: (_, __) =>
charts.MaterialPalette.blue.shadeDefault,
domainFn: (Stat stat, _)=> stat.month,
measureFn: (Stat stat, _) => stat.amount,
data: stats.monthlyIncomes.data,
)
];
从我看到的内容来看,我确实在执行示例所显示的内容,但是我收到此错误-我需要解决什么问题?
From what I can see I'm doing exactly what the example is showing, but I'm receiving this error - what would i need to resolve this ?
推荐答案
将您的 seriesList
声明更改为
List<charts.Series<Stat, num>> seriesList= []
这篇关于接收类型为"List<系列<动态,动态>>"的运行时错误不是'List< Series< dynamic,num>>'类型的子类型chart_flutter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文