Repository: flutter
Issue: Dragging a list that is currently handling an animateTo animation throws exception
Labels: framework,a: animation,f: scrolling,d: api docs,d: examples,customer: crowd,P2,workaround available,team-framework,triaged-framework

## Steps to Reproduce

The end goal is to create a scrolling list that automatically "snaps" to a given location based on the actual scroll position at which the user stops scrolling. This may not be the best solution (I'm new to Flutter), but here's the process by which I get the crash:

Wrap a ListView within a NotificationListener. Upon receiving a `UserScrollNotification` with `ScrollDirection.idle`, call the ScrollController's `animateTo()` method to scroll to another location (in the example here, I arbitrarily scroll to 10000.0 pixels).

### Sample code
```dart
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Scroller issue',
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final _controller = new ScrollController();

  bool _didGetNotification(ScrollNotification notification) {
    if (notification is UserScrollNotification) {
      if (notification.direction.toString() == "ScrollDirection.idle") {
        // We've stopped scrolling... now animate automatically to the 10000-pixel spot
        _controller.animateTo(10000.0, duration: const Duration(seconds: 2), curve: Curves.elasticOut);

        /* Above works great... unless the user tries to interact with the list WHILE it's
        // animating. In this case, you end up with:
        **********************************************************************************
        Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart':
          Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
        ********************************************************************************** */
      }
    }
    return true;
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new NotificationListener(
        onNotification: _didGetNotification,
        child: new ListView.builder(
          padding: new EdgeInsets.all(8.0),
          controller: _controller,
          itemExtent: 60.0,
          itemBuilder: (BuildContext context, int index) {
            return new Text('Item No. $index');
          },
        ),
      ),
    );
  }
}
```


It works great as long as the user only interacts with the ListView when it is idle, but if the user attempts to scroll/drag/touch the list _during_ the animateTo() process, the following exception is raised within the Flutter Scrollable package:

```
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
```

After this, the ListView becomes unresponsive.

I'm sure there's a better way to achieve what I'm trying to do, but the platform itself doesn't seem to recover from this. Figured I'd make a note of it. 


Thanks!


## Logs

Run your application with `flutter run` and attach all the log output.

```
    CADisplay.name = LCD;
    CADisplay.deviceName = PurpleMain;
    CADisplay.seed = 1;
    tags = 0;
    currentMode = <FBSDisplayMode: 0x604000097430; 375x667@2x (750x1334/2) 60Hz sRGB SDR>;
    safeOverscanRatio = {0.89999997615814209, 0.89999997615814209};
    nativeCenter = {375, 667};
    pixelSize = {750, 1334};
    bounds = {{0, 0}, {375, 667}};
    CADisplay = <CADisplay:LCD PurpleMain>;
}
Syncing files to device iPhone 6s...                  1.9s

🔥  To hot reload your app on the fly, press "r". To restart the app entirely, press "R".
An Observatory debugger and profiler on iPhone 6s is available at: http://127.0.0.1:8100/
For a more detailed help message, press "h". To quit, press "q".
══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 467 pos 12: '_hold == null':
is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new

When the exception was thrown, this was the stack:
#2      ScrollableState._handleDragStart (package:flutter/src/widgets/scrollable.dart:467:12)
#3      DragGestureRecognizer.acceptGesture.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:169:54)
#4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#5      DragGestureRecognizer.acceptGesture (package:flutter/src/gestures/monodrag.dart:169:9)
#6      GestureArenaManager._resolveByDefault (package:flutter/src/gestures/arena.dart:250:25)
#7      GestureArenaManager._tryToResolveArena.<anonymous closure> (package:flutter/src/gestures/arena.dart:231:31)
(elided 4 frames from class _AssertionError and package dart:async)

Handler: onStart
Recognizer:
VerticalDragGestureRecognizer#6eafd
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 472 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 478 pos 12: '_hold == null || _drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 455 pos 12: '_drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 464 pos 12: '_drag == null': is not true.
Another exception was thrown: 'package:flutter/src/widgets/scrollable.dart': Failed assertion: line 478 pos 12: '_hold == null || _drag == null': is not true.

```

Run `flutter analyze` and attach any output of that command also.

```
Analyzing /Users/mfahy/Apps/list_view_attempts...
No issues found!
Ran in 6.5s
```

## Flutter Doctor
```
[  +21 ms] [/Users/mfahy/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +36 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/alpha
[        ] [/Users/mfahy/flutter/] git rev-parse --abbrev-ref HEAD
[   +7 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] alpha
[        ] [/Users/mfahy/flutter/] git ls-remote --get-url origin
[   +9 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] [/Users/mfahy/flutter/] git log -n 1 --pretty=format:%H
[  +28 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 2e449f06f0a3be076e336ad6b30b0e9ec99dbdfe
[        ] [/Users/mfahy/flutter/] git log -n 1 --pretty=format:%ar
[  +10 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 5 days ago
[        ] [/Users/mfahy/flutter/] git describe --match v*.*.* --first-parent --long --tags
[  +44 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v0.0.21-0-g2e449f06f
[ +473 ms] /usr/bin/defaults read /Applications/Android Studio.app/Contents/Info CFBundleShortVersionString
[+1263 ms] Exit code 0 from: /usr/bin/defaults read /Applications/Android Studio.app/Contents/Info CFBundleShortVersionString
[        ] 3.0
[ +452 ms] [✓] Flutter (on Mac OS X 10.13.3 17D47, locale en-US, channel alpha)
[   +1 ms]     • Flutter version 0.0.21 at /Users/mfahy/flutter
[        ]     • Framework revision 2e449f06f0 (5 days ago), 2018-01-29 14:26:51 -0800
[        ]     • Engine revision 6921873c71
[        ]     • Tools Dart version 2.0.0-dev.16.0
[        ]     • Engine Dart version 2.0.0-edge.da1f52592ef73fe3afa485385cb995b9aec0181a
[ +130 ms] /usr/bin/defaults read /Applications/Android Studio.app/Contents/Info CFBundleShortVersionString
[ +218 ms] Exit code 0 from: /usr/bin/defaults read /Applications/Android Studio.app/Contents/Info CFBundleShortVersionString
[        ] 3.0
[  +98 ms] java -version
[  +87 ms] [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[        ]     • Android SDK at /Users/mfahy/Library/Android/sdk
[        ]     • Android NDK location not configured (optional; useful for native profiling support)
[        ]     • Platform android-27, build-tools 27.0.3
[        ]     • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[+1189 ms] DevToolsSecurity -status
[  +49 ms] Developer mode is currently enabled.
[        ] python -c import six
[ +126 ms] idevice_id -h
[  +10 ms] idevice_id -h
[   +9 ms] idevice_id -l
[  +28 ms] 5a62f0e8de345b9794b9a61c9bfcd02026c68a86
[   +1 ms] idevicename
[  +44 ms] ios-deploy --version
[  +54 ms] ios-deploy --version
[  +16 ms] 1.9.2
[   +1 ms] ios-deploy --version
[  +33 ms] ios-deploy --version
[  +21 ms] 1.9.2
[   +2 ms] pod --version
[ +905 ms] pod --version
[ +605 ms] 1.3.1
[   +2 ms] pod --version
[ +533 ms] 1.3.1
[   +1 ms] [-] iOS toolchain - develop for iOS devices (Xcode 9.2)
[        ]     • Xcode at /Applications/Xcode.app/Contents/Developer
[        ]     • Xcode 9.2, Build version 9C40b
[        ]     ✗ Verify that all connected devices have been paired with this computer in Xcode.
                 If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
                 To update, run:
                   brew uninstall --ignore-dependencies libimobiledevice
                   brew install --HEAD libimobiledevice
                   brew install ideviceinstaller
[        ]     • ios-deploy 1.9.2
[        ]     • CocoaPods version 1.3.1
[   +2 ms] [✓] Android Studio (version 3.0)
[        ]     • Android Studio at /Applications/Android Studio.app/Contents
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[   +6 ms] /usr/bin/defaults read /Applications/IntelliJ IDEA.app/Contents/Info CFBundleShortVersionString
[ +249 ms] Exit code 0 from: /usr/bin/defaults read /Applications/IntelliJ IDEA.app/Contents/Info CFBundleShortVersionString
[        ] 2017.3.4
[  +79 ms] [✓] IntelliJ IDEA Ultimate Edition (version 2017.3.4)
[        ]     • Flutter plugin version 21.2.3
[        ]     • Dart plugin version 173.4548.30
[   +4 ms] /Users/mfahy/Library/Android/sdk/platform-tools/adb devices -l
[  +17 ms] Exit code 0 from: /Users/mfahy/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
[   +8 ms] idevice_id -h
[  +82 ms] which ideviceinstaller
[   +5 ms] Exit code 0 from: which ideviceinstaller
[        ] /usr/local/bin/ideviceinstaller
[        ] which iproxy
[   +4 ms] Exit code 0 from: which iproxy
[        ] /usr/local/bin/iproxy
[   +4 ms] /usr/bin/xcrun simctl list --json devices
[ +218 ms] [✓] Connected devices
[        ]     • ViPhone 6S • 5a62f0e8de345b9794b9a61c9bfcd02026c68a86 • ios • iOS 11.3
[        ]     • iPhone 6s  • 6F36E8FD-E570-453E-B943-8243E4FAEDD6     • ios • iOS 11.2 (simulator)
[  +21 ms] "flutter doctor" took 6,972ms.
[  +42 ms] ensureAnalyticsSent: 38ms
[   +2 ms] exiting with code 0
```

Hope this helps! Thanks!