我正在尝试使用包创建一个饼图,并且想知道是否可以使用颤振小部件fl_chart
将元素包装起来。sections
...
PieChart(
PieChartData(
pieTouchData: pieTouchData,
borderData: FlBorderData(
show: false,
),
centerSpaceRadius: 0,
sections: sections,
sectionsSpace: sections[index].value == 0 ? 0 : 1,
),
)
...
这是部分的代码片段:
...
sections = List.generate(
categoryList.length,
(int sectionIndex) {
return PieChartSectionData(
titlePositionPercentageOffset: .98,
titleStyle: TextSetting.title24.copyWith(
fontFamily: "Parisienne",
color: Colors.white,
fontSize: fontSize),
radius: radius,
color: widget.transactionType ==
TransactionType.expense
? AppColour.expensesColor[sectionIndex]
: AppColour.incomesColor[sectionIndex],
title: categoryList[sectionIndex],
showTitle: value == 0 ? false : true,
value: value,
);
},
);
...
附加Im not sure this will be useful but just to clarify more
::
sections = [PieChartSectionData(........),
PieChartSectionData(......),
]
预期的结果应该是:
sections = [FlutterWidget(child: PieChartSectionData(...), FlutterWidget(child: PieChartSectionData(...)];
我按预期做的错误是:
error: The argument type 'PieChartSectionData' can't be assigned to the parameter type 'Widget'. (argument_type_not_assignable at [expense_tracker] lib\screens\analysis_screen_component\monthly_piechart.dart:121)
据我了解,这是因为 PieChartSectionData 不是小部件,但是我可以做些什么来使其成为小部件的一部分?
谢谢!