我正在尝试开发一个图表,但当make flutter运行代码时会发生什么?我无法编译应用程序。我的代码没有错误,但无法运行。我在编译此代码时出错了吗?如何检查此问题。有人可以帮助我的代码吗?
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
void main() {
runApp(const MyApp());
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late TooltipBehavior _tooltipBehavior;
@override
void initState() {
_tooltipBehavior = TooltipBehavior(enable: true);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('afadff'),
),
body: Center(
child: Container(
child: SfCartesianChart(
// Enables the tooltip for all the series in chart
tooltipBehavior: _tooltipBehavior,
// Initialize category axis
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
// Initialize line series
LineSeries<ChartData, String>(
// Enables the tooltip for individual series
enableTooltip: true,
dataSource: [
// Bind data source
ChartData('Jan', 35),
ChartData('Feb', 28),
ChartData('Mar', 34),
ChartData('Apr', 32),
ChartData('May', 40)
],
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y)
]))));
}
}
class ChartData {
ChartData(this.x, this.y);
final String x;
final double? y;
}
1条答案
按热度按时间sdnqo3pr1#
在您提供的代码片段中,我似乎找不到
onPointerPanZoomUpdate
。错误指示找不到onPointerPanZoomUpdate。Listener
回调onPointerPanZoomUpdate从Flutter 3.3开始可用。如果您使用的是旧版本的Flutter,则需要在终端上运行flutter upgrade
以升级您的Flutter版本。