Create one listener that merges the leading and trailing glow controllers and use it in each paint (#11311)

If a new listener is created for each paint, then the leading and trailing
controllers will accumulate and invoke a list of all those listeners
This commit is contained in:
Jason Simmons 2017-07-19 17:32:39 -07:00 committed by GitHub
parent 741598d848
commit 6dbf2269f0

View File

@ -117,12 +117,14 @@ class GlowingOverscrollIndicator extends StatefulWidget {
class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator> with TickerProviderStateMixin { class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator> with TickerProviderStateMixin {
_GlowController _leadingController; _GlowController _leadingController;
_GlowController _trailingController; _GlowController _trailingController;
Listenable _leadingAndTrailingListener;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_leadingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis); _leadingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis);
_trailingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis); _trailingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis);
_leadingAndTrailingListener = new Listenable.merge(<Listenable>[_leadingController, _trailingController]);
} }
@override @override
@ -210,6 +212,7 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
leadingController: widget.showLeading ? _leadingController : null, leadingController: widget.showLeading ? _leadingController : null,
trailingController: widget.showTrailing ? _trailingController : null, trailingController: widget.showTrailing ? _trailingController : null,
axisDirection: widget.axisDirection, axisDirection: widget.axisDirection,
repaint: _leadingAndTrailingListener,
), ),
child: new RepaintBoundary( child: new RepaintBoundary(
child: widget.child, child: widget.child,
@ -444,8 +447,9 @@ class _GlowingOverscrollIndicatorPainter extends CustomPainter {
this.leadingController, this.leadingController,
this.trailingController, this.trailingController,
this.axisDirection, this.axisDirection,
Listenable repaint,
}) : super( }) : super(
repaint: new Listenable.merge(<Listenable>[leadingController, trailingController]) repaint: repaint,
); );
/// The controller for the overscroll glow on the side with negative scroll offsets. /// The controller for the overscroll glow on the side with negative scroll offsets.