1+ // ignore_for_file: must_be_immutable
2+
13import 'package:intl/intl.dart' ;
24import 'package:flutter/material.dart' ;
35import 'package:syncfusion_flutter_charts/charts.dart' ;
@@ -11,7 +13,7 @@ class SynchronizedZoomPan extends StatelessWidget {
1113
1214 @override
1315 Widget build (BuildContext context) {
14- return const MaterialApp (
16+ return MaterialApp (
1517 debugShowCheckedModeBanner: false ,
1618 title: 'Synchronized ZoomPan' ,
1719 home: Scaffold (
@@ -32,17 +34,19 @@ DateTimeAxisController? _secondAxisController;
3234DataModel _dataModel = DataModel ();
3335
3436class FirstChart extends StatelessWidget {
35- const FirstChart ({super .key});
37+ FirstChart ({super .key});
38+
39+ final ZoomPanBehavior _zoomPanBehavior = ZoomPanBehavior (
40+ enablePanning: true ,
41+ enablePinching: true ,
42+ enableDoubleTapZooming: true ,
43+ zoomMode: ZoomMode .x);
3644
3745 @override
3846 Widget build (BuildContext context) {
3947 return SfCartesianChart (
4048 backgroundColor: Colors .white,
41- zoomPanBehavior: ZoomPanBehavior (
42- enablePanning: true ,
43- enablePinching: true ,
44- enableDoubleTapZooming: true ,
45- zoomMode: ZoomMode .x),
49+ zoomPanBehavior: _zoomPanBehavior,
4650 onZooming: (ZoomPanArgs args) {
4751 if (args.axis! .name == 'primaryXAxis' ) {
4852 _secondAxisController! .zoomFactor = args.currentZoomFactor;
@@ -80,17 +84,19 @@ class FirstChart extends StatelessWidget {
8084}
8185
8286class SecondChart extends StatelessWidget {
83- const SecondChart ({super .key});
87+ SecondChart ({super .key});
88+
89+ final ZoomPanBehavior _zoomPanBehavior = ZoomPanBehavior (
90+ enablePanning: true ,
91+ enablePinching: true ,
92+ enableDoubleTapZooming: true ,
93+ zoomMode: ZoomMode .x);
8494
8595 @override
8696 Widget build (BuildContext context) {
8797 return SfCartesianChart (
8898 backgroundColor: Colors .white,
89- zoomPanBehavior: ZoomPanBehavior (
90- enablePanning: true ,
91- enablePinching: true ,
92- enableDoubleTapZooming: true ,
93- zoomMode: ZoomMode .x),
99+ zoomPanBehavior: _zoomPanBehavior,
94100 onZooming: (ZoomPanArgs args) {
95101 if (args.axis! .name == 'primaryXAxis' ) {
96102 _firstAxisController! .zoomFactor = args.currentZoomFactor;
0 commit comments