Repository: flutter
Issue: palette_generator sample is not reliable; _onPanUpdate called before _onPanDown
Labels: package,p: palette_generator,team-ecosystem,P3,triaged-ecosystem

When you select a sub-area using [palette_generator sample](https://github.com/flutter/packages/tree/master/packages/palette_generator), `_onPanEnd` is called [asynchronously](https://github.com/flutter/packages/blob/db155615d189250f2d357ab5674dc9a732b6c8ce/packages/palette_generator/example/lib/main.dart#L120), but everything else is called synchronously. So it happens that `onPanUpdate` is called before `onPanDown` has happened, which makes [startDrag](https://github.com/flutter/packages/blob/db155615d189250f2d357ab5674dc9a732b6c8ce/packages/palette_generator/example/lib/main.dart#L106) become null.

The issue happens sometimes (not every time, but not uncommon), when you are selecting multiple times, it throws exceptions and don't show any result. If you make `_onPanEnd` work synchronously, this issue is solved but there is.. well.. the slowdown issue because it would work on main thread.

```
The following NoSuchMethodError was thrown while handling a gesture:
The getter 'dx' was called on null.
Receiver: null
Tried calling: dx

When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      new Rect.fromPoints (dart:ui/geometry.dart:659:16)
#2      _ImageColorsState._onPanUpdate.<anonymous closure> (package:material/image_picker.dart:247:25)
#3      State.setState (package:flutter/src/widgets/framework.dart:1141:30)
#4      _ImageColorsState._onPanUpdate (package:material/image_picker.dart:244:5)
...
Handler: "onUpdate"
Recognizer: PanGestureRecognizer#e7f04
  debugOwner: GestureDetector
  start behavior: start
```

```
E/flutter (20190): Receiver: null
E/flutter (20190): Tried calling: left
E/flutter (20190): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (20190): #1      Rect.intersect (dart:ui/geometry.dart:750:28)
E/flutter (20190): #2      _ImageColorsState._onPanEnd (package:material/image_picker.dart:267:54)
E/flutter (20190): <asynchronous suspension>
E/flutter (20190): #3      DragGestureRecognizer._checkEnd.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:439:41)
E/flutter (20190): #4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (20190): #5      DragGestureRecognizer._checkEnd (package:flutter/src/gestures/monodrag.dart:439:5)
E/flutter (20190): #6      DragGestureRecognizer.didStopTrackingLastPointer (package:flutter/src/gestures/monodrag.dart:348:9)
E/flutter (20190): #7      OneSequenceGestureRecognizer.stopTrackingPointer (package:flutter/src/gestures/recognizer.dart:336:9)
E/flutter (20190): #8      DragGestureRecognizer._giveUpPointer (package:flutter/src/gestures/monodrag.dart:357:5)
E/flutter (20190): #9      DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:281:7)
E/flutter (20190): #10     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:75:13)
E/flutter (20190): #11     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:102:11)
E/flutter (20190): #12     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (20190): #13     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (20190): #14     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (20190): #15     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (20190): #16     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (20190): #17     _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (20190): #18     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (20190): #19     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (20190): #20     _invoke1 (dart:ui/hooks.dart:263:10)
E/flutter (20190): #21     _dispatchPointerDataPacket (dart:ui/hooks.dart:172:5)
```


```
➜ flutter doctor -v
[✓] Flutter (Channel dev, v1.10.1, on Mac OS X 10.14.6 18G95, locale en-BR)
    • Flutter version 1.10.1 at /usr/local/Cellar/flutter/dev
    • Framework revision ce45c2d3e6 (6 days ago), 2019-09-06 20:11:41 -0400
    • Engine revision b9ce2500d9
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 be66176534)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/bernardoferrari/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Users/bernardoferrari/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android
      Studio 3.5 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.3

[✓] Android Studio (version 3.5)
    • Android Studio at /Users/bernardoferrari/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android
      Studio 3.5 Preview.app/Contents
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build
      1.8.0_202-release-1483-b49-5587405)

[✓] Android Studio
    • Android Studio at /Users/bernardoferrari/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/192.5863777/Android
      Studio 3.6 Preview.app/Contents
    • Flutter plugin version 39.0.4
    • Dart plugin version 192.6527
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
    • IntelliJ at /Users/bernardoferrari/Applications/JetBrains Toolbox/IntelliJ
      IDEA Ultimate.app
    • Flutter plugin version 38.2.4
    • Dart plugin version 192.6459

[✓] VS Code (version 1.38.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 10
      (API 29) (emulator)

• No issues found!
```