File tree Expand file tree Collapse file tree 3 files changed +34
-8
lines changed
Expand file tree Collapse file tree 3 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -273,7 +273,8 @@ class ChartPainter extends CustomPainter {
273273 }
274274
275275 @override
276- bool shouldRepaint (ChartPainter oldDelegate) => true ;
276+ bool shouldRepaint (ChartPainter oldDelegate) =>
277+ params.shouldRepaint (oldDelegate.params);
277278}
278279
279280extension ElementAtOrNull <E > on List <E > {
Original file line number Diff line number Diff line change @@ -141,13 +141,15 @@ class _InteractiveChartState extends State<InteractiveChart> {
141141 duration: Duration (milliseconds: 300 ),
142142 curve: Curves .easeOut,
143143 builder: (_, PainterParams params, __) {
144- return CustomPaint (
145- size: size,
146- painter: ChartPainter (
147- params: params,
148- getTimeLabel: widget.timeLabel ?? defaultTimeLabel,
149- getPriceLabel: widget.priceLabel ?? defaultPriceLabel,
150- getOverlayInfo: widget.overlayInfo ?? defaultOverlayInfo,
144+ return RepaintBoundary (
145+ child: CustomPaint (
146+ size: size,
147+ painter: ChartPainter (
148+ params: params,
149+ getTimeLabel: widget.timeLabel ?? defaultTimeLabel,
150+ getPriceLabel: widget.priceLabel ?? defaultPriceLabel,
151+ getOverlayInfo: widget.overlayInfo ?? defaultOverlayInfo,
152+ ),
151153 ),
152154 );
153155 },
Original file line number Diff line number Diff line change @@ -83,6 +83,29 @@ class PainterParams {
8383 trailingTrend: b.trailingTrend,
8484 );
8585 }
86+
87+ bool shouldRepaint (PainterParams other) {
88+ if (candles.length != other.candles.length) return true ;
89+
90+ if (size != other.size ||
91+ candleWidth != other.candleWidth ||
92+ startOffset != other.startOffset ||
93+ xShift != other.xShift) return true ;
94+
95+ if (maxPrice != other.maxPrice ||
96+ minPrice != other.minPrice ||
97+ maxVol != other.maxVol ||
98+ minVol != other.minVol) return true ;
99+
100+ if (tapPosition != other.tapPosition) return true ;
101+
102+ if (leadingTrend != other.leadingTrend ||
103+ trailingTrend != other.trailingTrend) return true ;
104+
105+ if (style != other.style) return true ;
106+
107+ return false ;
108+ }
86109}
87110
88111class PainterParamsTween extends Tween <PainterParams > {
You can’t perform that action at this time.
0 commit comments