_generatePieChartSectionData(recievedData) {
print(recievedData);
int len = recievedData.length();
for (int i = 0; i < len; i++) {
_pieChartdata.add(charts.PieChartSectionData(
color: Color(int.parse(recievedData[i].color)),
title: recievedData[i].name,
value: double.parse(recievedData[i].value),
));
}
Widget _bodyBuild(context) {
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('pieChart').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return LinearProgressIndicator();
} else {
List<ManHours> man = snapshot.data.documents
.map((documentSnapshot) => ManHours.from(documentSnapshot.data))
.toList();
return _buildPie(context, man);
}
},
);
}
Widget _buildPie(BuildContext context, List<ManHours> man) {
recievedData = man;
print('ghfghfghfhgfghfhgfhfghfghfgfhfh');
print(recievedData.toString());
_generatePieChartSectionData(recievedData);
print('kk');
return Center(
child: charts.PieChart(charts.PieChartData(
sections: _pieChartdata,
sectionsSpace: 5.0,
centerSpaceRadius: 40.0,
)),
);
}
这是我在 android studio 中收到的错误消息。我认为这与_generatePieChartSectionData函数有关,或者可能与StreamBuilder 有关
另外,请提供有关任何有助于我理解颤振错误消息的资源的建议
>/flutter ( 8961): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY>╞═══════════════════════════════════════════════════════════
>I/flutter ( 8961): The following NoSuchMethodError was thrown building StreamBuilder<QuerySnapshot (dirty, state:
>I/flutter ( 8961): _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot<QuerySnapshot>>#19026): >I/flutter ( 8961): Class 'int' has no instance method 'call'.
>I/flutter ( 8961): Receiver: 6
>I/flutter ( 8961): Tried calling: call()
>I/flutter ( 8961):
>I/flutter ( 8961): The relevant error-causing widget was:
>I/flutter ( 8961): StreamBuilder<QuerySnapshot>
>I/flutter ( 8961): >file:///G:/FLUTTER_PROJECTS/charts_unergia/lib/activities/pieChartActivity.dart:40:12