Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
// Enables the legend
legend: Legend(isVisible: true),
// Initialize category axis
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
// Initialize line series
LineSeries<GraphModel, String>(
dataSource: [
// Bind data source
// retrieve data from database
GraphModel(
productName: ['prodName'], count: 'count'.length
),
],
xValueMapper: (GraphModel data, _) => data.productName,
yValueMapper: (GraphModel data, _) => data.count,
)
]
)
)
)
);
}
}
我想从创建GraphModel的firestore中检索数据,但我不知道如何声明从firebase到图中的输入。请帮助我如何声明此图
1条答案
按热度按时间juzqafwq1#
我需要将
cloud_firestore
软件包导入到pubspec.yaml文件中下面是从firestore检索数据的完整代码: