Commit 445c512d authored by Adam Barth's avatar Adam Barth

Be a bit less clever with ??=

Turns out .. binds tigher than ??= according to
https://www.dartlang.org/docs/dart-up-and-running/ch02.html#operators, which
means we were only updating the callbacks when we first created the
recognizers. Now we update them unconditionally.
parent 426ce937
...@@ -100,8 +100,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -100,8 +100,8 @@ class GestureDetectorState extends State<GestureDetector> {
if (config.onTap == null) { if (config.onTap == null) {
_tap = _ensureDisposed(_tap); _tap = _ensureDisposed(_tap);
} else { } else {
_tap ??= new TapGestureRecognizer(router: _router) _tap ??= new TapGestureRecognizer(router: _router);
..onTap = config.onTap; _tap.onTap = config.onTap;
} }
} }
...@@ -109,8 +109,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -109,8 +109,8 @@ class GestureDetectorState extends State<GestureDetector> {
if (config.onShowPress == null) { if (config.onShowPress == null) {
_showPress = _ensureDisposed(_showPress); _showPress = _ensureDisposed(_showPress);
} else { } else {
_showPress ??= new ShowPressGestureRecognizer(router: _router) _showPress ??= new ShowPressGestureRecognizer(router: _router);
..onShowPress = config.onShowPress; _showPress.onShowPress = config.onShowPress;
} }
} }
...@@ -118,8 +118,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -118,8 +118,8 @@ class GestureDetectorState extends State<GestureDetector> {
if (config.onLongPress == null) { if (config.onLongPress == null) {
_longPress = _ensureDisposed(_longPress); _longPress = _ensureDisposed(_longPress);
} else { } else {
_longPress ??= new LongPressGestureRecognizer(router: _router) _longPress ??= new LongPressGestureRecognizer(router: _router);
..onLongPress = config.onLongPress; _longPress.onLongPress = config.onLongPress;
} }
} }
...@@ -127,7 +127,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -127,7 +127,8 @@ class GestureDetectorState extends State<GestureDetector> {
if (config.onVerticalDragStart == null && config.onVerticalDragUpdate == null && config.onVerticalDragEnd == null) { if (config.onVerticalDragStart == null && config.onVerticalDragUpdate == null && config.onVerticalDragEnd == null) {
_verticalDrag = _ensureDisposed(_verticalDrag); _verticalDrag = _ensureDisposed(_verticalDrag);
} else { } else {
_verticalDrag ??= new VerticalDragGestureRecognizer(router: _router) _verticalDrag ??= new VerticalDragGestureRecognizer(router: _router);
_verticalDrag
..onStart = config.onVerticalDragStart ..onStart = config.onVerticalDragStart
..onUpdate = config.onVerticalDragUpdate ..onUpdate = config.onVerticalDragUpdate
..onEnd = config.onVerticalDragEnd; ..onEnd = config.onVerticalDragEnd;
...@@ -138,7 +139,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -138,7 +139,8 @@ class GestureDetectorState extends State<GestureDetector> {
if (config.onHorizontalDragStart == null && config.onHorizontalDragUpdate == null && config.onHorizontalDragEnd == null) { if (config.onHorizontalDragStart == null && config.onHorizontalDragUpdate == null && config.onHorizontalDragEnd == null) {
_horizontalDrag = _ensureDisposed(_horizontalDrag); _horizontalDrag = _ensureDisposed(_horizontalDrag);
} else { } else {
_horizontalDrag ??= new HorizontalDragGestureRecognizer(router: _router) _horizontalDrag ??= new HorizontalDragGestureRecognizer(router: _router);
_horizontalDrag
..onStart = config.onHorizontalDragStart ..onStart = config.onHorizontalDragStart
..onUpdate = config.onHorizontalDragUpdate ..onUpdate = config.onHorizontalDragUpdate
..onEnd = config.onHorizontalDragEnd; ..onEnd = config.onHorizontalDragEnd;
...@@ -150,7 +152,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -150,7 +152,8 @@ class GestureDetectorState extends State<GestureDetector> {
_pan = _ensureDisposed(_pan); _pan = _ensureDisposed(_pan);
} else { } else {
assert(_scale == null); // Scale is a superset of pan; just use scale assert(_scale == null); // Scale is a superset of pan; just use scale
_pan ??= new PanGestureRecognizer(router: _router) _pan ??= new PanGestureRecognizer(router: _router);
_pan
..onStart = config.onPanStart ..onStart = config.onPanStart
..onUpdate = config.onPanUpdate ..onUpdate = config.onPanUpdate
..onEnd = config.onPanEnd; ..onEnd = config.onPanEnd;
...@@ -162,7 +165,8 @@ class GestureDetectorState extends State<GestureDetector> { ...@@ -162,7 +165,8 @@ class GestureDetectorState extends State<GestureDetector> {
_scale = _ensureDisposed(_scale); _scale = _ensureDisposed(_scale);
} else { } else {
assert(_pan == null); // Scale is a superset of pan; just use scale assert(_pan == null); // Scale is a superset of pan; just use scale
_scale ??= new ScaleGestureRecognizer(router: _router) _scale ??= new ScaleGestureRecognizer(router: _router);
_scale
..onStart = config.onScaleStart ..onStart = config.onScaleStart
..onUpdate = config.onScaleUpdate ..onUpdate = config.onScaleUpdate
..onEnd = config.onScaleEnd; ..onEnd = config.onScaleEnd;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment