Repository: flutter
Issue: [tests] Simulating a fling gesture with infinite speed, detects a velocity of 0.0 
Labels: a: tests,framework,f: gestures,has reproducible steps,P2,found in release: 2.10,found in release: 2.13,team-framework,triaged-framework

## Steps to Reproduce

1. Execute `flutter test` on the code sample <!-- (see "Code sample" section below) -->
-> This code sample provide a basic `GestureDetector` with a callback on the `onPanEnd` prop and a unit test that emulates a fling gesture with an infinite speed:
``` dart
 await tester.flingFrom(
      const Offset(200, 200), // startLocation
      const Offset(0, 100), // offset
      double.infinity, // speed <------- We pass an infinite speed
    );
```
and expects the velocity of the detected gesture to be equally infinite:
```
expect(
        details.velocity.pixelsPerSecond.dy,
        equals(double.infinity), // <------- We expect an infinite speed
      );
``` 

**Expected results:** The test is expected to pass

**Actual results:** The test fails because the actual velocity of the detected gesture is `0.0` instead of `Infinity`

<img width="1590" alt="image" src="https://user-images.githubusercontent.com/4828287/162438250-77d28fc3-32d2-4120-af82-c945ee0aeba8.png">


<details>
<summary>Code sample</summary>

`main.dart`
```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  final void Function(DragEndDetails)? onGestureDetected;

  @override
  _MyAppState createState() => _MyAppState();

  MyApp({this.onGestureDetected});
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        body: GestureDetector(
          onPanEnd: (DragEndDetails details) {
            widget.onGestureDetected?.call(details);
          },
          child: Container(
            color: Colors.amber,
          ),
        ),
      ),
    );
  }
}
```

`widget_test.dart`
``` dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_sandbox/main.dart';

void main() {
  testWidgets(
      'should detect a gesture with Infinite velocity when fling gesture is performed with an infinite speed',
      (WidgetTester tester) async {
    await tester.pumpWidget(MyApp(onGestureDetected: (DragEndDetails details) {
      expect(
        details.velocity.pixelsPerSecond.dy,
        equals(double.infinity), // <------- We expect an infinite speed
      );
    }));
    await tester.flingFrom(
      const Offset(200, 200), // startLocation
      const Offset(0, 100), // offset
      double.infinity, // speed <------- We pass an infinite speed
    );
  });
}
``` 

</details>

<details>
  <summary>Logs</summary>

Running `flutter test --verbose`:

```
[ +116 ms] executing: sysctl hw.optional.arm64
[  +22 ms] Exit code 1 from: sysctl hw.optional.arm64
[   +1 ms] sysctl: unknown oid 'hw.optional.arm64'
[  +11 ms] executing: [~/fvm/versions/stable/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +17 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 7e9793dee1b85a243edd0e06cb1658e98b077561
[   +1 ms] executing: [~/fvm/versions/stable/] git tag --points-at 7e9793dee1b85a243edd0e06cb1658e98b077561
[ +173 ms] Exit code 0 from: git tag --points-at 7e9793dee1b85a243edd0e06cb1658e98b077561
[        ] 2.10.3
[  +12 ms] executing: [~/fvm/versions/stable/] git rev-parse --abbrev-ref --symbolic @{u}
[  +17 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [~/fvm/versions/stable/] git ls-remote --get-url origin
[  +16 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +132 ms] executing: [~/fvm/versions/stable/] git rev-parse --abbrev-ref HEAD
[  +18 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[   +7 ms] executing: sw_vers -productName
[  +20 ms] Exit code 0 from: sw_vers -productName
[        ] macOS
[        ] executing: sw_vers -productVersion
[  +29 ms] Exit code 0 from: sw_vers -productVersion
[        ] 12.2
[        ] executing: sw_vers -buildVersion
[  +23 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 21D5025f
[  +91 ms] Found 1 files which will be executed as Widget Tests.
[  +13 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +8 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +77 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +137 ms] Skipping pub get: version match.
[  +99 ms] Generating ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[ +165 ms] running test package with arguments: [-r, compact, --timeout, 30s, --concurrency=2, --chain-stack-traces, --, ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/test/widget_test.dart]
00:00 +0: loading ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/test/widget_test.dart                                                                                                               [ +235 ms] test 0: starting test ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/test/widget_test.dart
[   +7 ms] Stopping scan for flutter_test_config.dart; found project root at ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox
[   +4 ms] Compiler will use the following file as its incremental dill file: /var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_compiler.E2JFXj/output.dill
[        ] Listening to compiler controller...
[  +15 ms] Compiling file:///var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_listener.vNi5QR/listener.dart
[  +43 ms] ~/fvm/versions/stable/bin/cache/dart-sdk/bin/dart --disable-dart-dev ~/fvm/versions/stable/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root
~/fvm/versions/stable/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --no-print-incremental-dependencies --target=flutter --debugger-module-names --experimental-emit-debug-metadata
-DFLUTTER_WEB_AUTO_DETECT=true --output-dill /var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_compiler.E2JFXj/output.dill --packages
~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --initialize-from-dill
~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/build/test_cache/build/c075001b96339384a97db4862b8ab8db.cache.dill.track.dill
[  +41 ms] <- compile file:///var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_listener.vNi5QR/listener.dart
00:01 +0: loading ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/test/widget_test.dart                                                                                                               [+1529 ms] <- accept
[        ] <- reset
[        ] Compiling file:///var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_listener.vNi5QR/listener.dart took 1614ms
[        ] test 0: starting test device
[   +6 ms] test 0: awaiting connection to test device
[   +2 ms] test 0: Observatory uri is not available
[   +6 ms] test 0: test harness socket server is running at port:53757
[   +9 ms] executing: sysctl hw.optional.arm64
[   +8 ms] Exit code 1 from: sysctl hw.optional.arm64
[        ] sysctl: unknown oid 'hw.optional.arm64'
[   +3 ms] Using this directory for fonts configuration: /var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_fonts.2377oY
[   +2 ms] test 0: Starting flutter_tester process with command=[~/fvm/versions/stable/bin/cache/artifacts/engine/darwin-x64/flutter_tester, --disable-observatory, --enable-checked-mode, --verify-entry-points,
--enable-software-rendering, --skia-deterministic-rendering, --enable-dart-profiling, --non-interactive, --use-test-fonts,
--packages=~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/.dart_tool/package_config.json,
/var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_listener.vNi5QR/listener.dart.dill], environment={FLUTTER_TEST: true, FONTCONFIG_FILE:
/var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_fonts.2377oY/fonts.conf, SERVER_PORT: 53757, APP_NAME: flutter_sandbox, UNIT_TEST_ASSETS:
~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/build/unit_test_assets}
[  +12 ms] test 0: Started flutter_tester process at pid 9825
00:02 +0: loading ~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/test/widget_test.dart                                                                                                               [ +651 ms] test 0: connected to test device, now awaiting test result
[        ] test 0: Waiting for test harness or tests to finish
00:03 +0: should detect a gesture with Infinite velocity when fling gesture is performed with an infinite speed                                                                                                                             
══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following TestFailure was thrown while handling a gesture:
Expected: <Infinity>
  Actual: <0.0>

When the exception was thrown, this was the stack:
#0      fail (package:test_api/src/expect/expect.dart:137:31)
#1      _expect (package:test_api/src/expect/expect.dart:132:3)
#2      expect (package:test_api/src/expect/expect.dart:46:3)
#3      expect (package:flutter_test/src/widget_tester.dart:455:16)
#4      main.<anonymous closure>.<anonymous closure> (file://~/Workshop/Workbench/Development/Projects/FlutterSandbox/flutter_sandbox/test/widget_test.dart:11:7)
#5      _MyAppState.build.<anonymous closure> (package:flutter_sandbox/main.dart:24:39)
#6      DragGestureRecognizer._checkEnd.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:485:47)
#7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24)
#8      DragGestureRecognizer._checkEnd (package:flutter/src/gestures/monodrag.dart:485:5)
#9      DragGestureRecognizer.didStopTrackingLastPointer (package:flutter/src/gestures/monodrag.dart:393:9)
#10     OneSequenceGestureRecognizer.stopTrackingPointer (package:flutter/src/gestures/recognizer.dart:392:9)
#11     DragGestureRecognizer._giveUpPointer (package:flutter/src/gestures/monodrag.dart:402:5)
#12     DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:321:7)
#13     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:94:12)
#14     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:139:9)
#15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:539:8)
#16     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:137:18)
#17     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:123:7)
#18     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:439:19)
#19     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
#20     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:322:11)
#21     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
#22     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
#23     TestWidgetsFlutterBinding.handlePointerEventForSource.<anonymous closure> (package:flutter_test/src/binding.dart:496:42)
#24     TestWidgetsFlutterBinding.withPointerEventSource (package:flutter_test/src/binding.dart:506:11)
#25     TestWidgetsFlutterBinding.handlePointerEventForSource (package:flutter_test/src/binding.dart:496:5)
#26     WidgetTester.sendEventToBinding.<anonymous closure> (package:flutter_test/src/widget_tester.dart:808:15)
#27     WidgetTester.sendEventToBinding.<anonymous closure> (package:flutter_test/src/widget_tester.dart:807:39)
#30     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#31     WidgetTester.sendEventToBinding (package:flutter_test/src/widget_tester.dart:807:27)
#32     WidgetController.flingFrom.<anonymous closure> (package:flutter_test/src/controller.dart:428:13)
<asynchronous suspension>
<asynchronous suspension>
(elided 3 frames from dart:async and package:stack_trace)

Handler: "onEnd"
Recognizer:
  PanGestureRecognizer#30423
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +0 -1: should detect a gesture with Infinite velocity when fling gesture is performed with an infinite speed [E]                                                                                                                      
  Test failed. See exception logs above.
  The test description was: should detect a gesture with Infinite velocity when fling gesture is performed with an infinite speed
  
[+1135 ms] test 0: Test harness is no longer needed by test process
[        ] test 0: finished
[   +3 ms] test 0: cleaning up...
[   +1 ms] test 0: ensuring test device is terminated.
[        ] test 0: Terminating flutter_tester process
[        ] test 0: Shutting down test harness socket server
[        ] test 0: Test process is no longer needed by test harness
[  +19 ms] test 0: flutter_tester process at pid 9825 exited with code=-9
[        ] test 0: deleting temporary directory
[   +4 ms] test 0: finished
00:03 +0 -1: Some tests failed.                                                                                                                                                                                                             
[  +16 ms] Deleting /var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_compiler.E2JFXj...
[   +4 ms] killing pid 9813
[  +38 ms] Deleting /var/folders/8x/t_9dz4397_d2b8vyqcny86f00000gn/T/flutter_tools.wPNtEH/flutter_test_fonts.2377oY...
[   +6 ms] test package returned with exit code 1
[  +14 ms] "flutter test" took 4,381ms.
[   +7 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      TestCommand.runCommand (package:flutter_tools/src/commands/test.dart:472:7)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>
           
           
[  +91 ms] ensureAnalyticsSent: 86ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1
```
Running `flutter analyze`

```
Analyzing flutter_sandbox...                                            
No issues found! (ran in 3.7s)
```

Running `flutter doctor -v`

```
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2 21D5025f darwin-x64, locale en-GB)
    • Flutter version 2.10.3 at /Users/guitoof/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (5 weeks ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/guitoof/Library/Android/sdk
    • Platform android-31, build-tools 32.0.0
    • ANDROID_HOME = /Users/guitoof/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] VS Code (version 1.66.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 93AA969D-B63F-4160-A3F9-5C1DD633D67C • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 12.2 21D5025f darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 100.0.4896.75
    ! Error: iToof is not connected. Xcode will continue when iToof is connected. (code -13)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>