gpt4 book ai didi

arrays - 在 Point Chart Flutter 中实现 List

转载 作者:IT王子 更新时间:2023-10-29 07:23:53 25 4
gpt4 key购买 nike

你能说出这段代码的区别吗:

final installmentList = [];
for (var i = 0; i < installment.length; i++) {
installmentList.add(new LinearStatistic(i, installment[i].count));
}

来自这段代码:

final data = [
new LinearStatistic(0, 5),
new LinearStatistic(1, 25),
new LinearStatistic(2, 100),
new LinearStatistic(3, 75),
];

当我调试并使用“data”变量时,返回语句被调用,但当我使用“instalmentList”变量时,它没有被调用。

return [
new charts.Series<LinearStatistic, int>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (LinearStatistic sales, _) => sales.position,
measureFn: (LinearStatistic sales, _) => sales.count,
data: data,
)
];
}

最佳答案

static List<charts.Series<LinearSales, int>> _createSampleData() {
// final data = [
// new LinearSales(0, 5),
// new LinearSales(1, 25),
// new LinearSales(2, 100),
// new LinearSales(3, 75),
// ];
List installment = [5, 10, 4, 22, 12];
final List installmentList = <LinearSales>[];
for (var i = 0; i < installment.length; i++) {
installmentList.add(new LinearSales(i, installment[i]));
}
return [
new charts.Series<LinearSales, int>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (LinearSales sales, _) => sales.year,
measureFn: (LinearSales sales, _) => sales.sales,
data: installmentList,
)
];}

使用此代码作为引用 这是我所做的更改 final List installmentList = <LinearSales>[];

Here is the Result

关于arrays - 在 Point Chart Flutter 中实现 List,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54036468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com