Skip to content

onPointerCancel of Listener in never called #93683

@gslender

Description

@gslender

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Tap down (but don't release) the amber square and move outside of the square and then release
  3. Pointer down event and pointer up event is sent, but pointer cancel should be sent.
  4. There seems to be no way to generate pointer cancel events, and either docs is wrong, or a bug exists

Expected results:
A pointer cancel event is sent when the input from a pointer that triggered an [onPointerDown] is no longer directed towards this receiver (as per what the docs suggest would happen).

Actual results:
No pointer cancel event is sent at all... and instead a pointer up event sent when the receiver should no longer be receiving events !?

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: ListenerTest(),
    );
  }
}

class ListenerTest extends StatefulWidget {
  const ListenerTest({Key? key}) : super(key: key);

  @override
  State<ListenerTest> createState() => _ListenerTestState();
}

class _ListenerTestState extends State<ListenerTest> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Listener Test'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Listener(
                onPointerDown: (pde) => debugPrint("$pde"),
                onPointerUp: (pue) => debugPrint("$pue"),
                onPointerCancel: (pce) => debugPrint("$pce"),
                child: Container(
                    width: 100,
                    height: 60,
                    color: Colors.amber,
                    child: const Text(
                      'ClickMe',
                    ))),
          ],
        ),
      ),
    );
  }
}
Logs
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale en-AU)
    • Flutter version 2.5.3 at /Users/gslender/Documents/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (4 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/gslender/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • 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.10+0-b96-7281165)

[✓] VS Code (version 1.62.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.28.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.6 20G165 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 95.0.4638.69

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: gesturesflutter/packages/flutter/gestures repository.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions