Skip to content

onLongPress and onSecondaryLongPress cannot be used together in a Gesture Detector #62895

Closed

Description

Steps to Reproduce

See the following DartPad and run it: https://dartpad.dev/b9360fd9b3c93ae8125af4992b3decf6

Expected results: long pressing Hello, World! should show a snack bar.

Actual results: only secondary long pressing it shows a snack bar. If I remove the onSecondaryLongPress callback, the onLongPress works again.

Activity

  1. pedromassangocode commented on Aug 5, 2020

    @pedromassangocode

    Also found at 1.21.0-1.0.pre.

    complete sample code
    import 'package:flutter/material.dart';
    
    final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: Center(
              child: Builder(
                builder: (context) {
                  return GestureDetector(
                    onLongPress: () {
                      Scaffold.of(context).showSnackBar(SnackBar(content: Text('primary')));
                    },
                    onSecondaryLongPress: () {
                      Scaffold.of(context).showSnackBar(SnackBar(content: Text('secondary')));
                    },
                    child: MyWidget(),
                  );
                },
              ),
            ),
          ),
        );
      }
    }
    
    class MyWidget extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Text('Hello, World!', style: Theme.of(context).textTheme.headline4);
      }
    }
    
    flutter doctor -v
    [✓] Flutter (Channel dev, 1.21.0-1.0.pre, on Mac OS X 10.15.6 19G73, locale en)
        • Flutter version 1.21.0-1.0.pre at /Users/pedromassango/dev/SDKs/flutter_dev
        • Framework revision f25bd9c55c (3 weeks ago), 2020-07-14 20:26:01 -0400
        • Engine revision 99c2b3a245
        • Dart version 2.9.0 (build 2.9.0-21.0.dev 20bf2fcf56)
    
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
        • Android SDK at /Users/pedromassango/Library/Android/sdk
        • Platform android-30, build-tools 30.0.1
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
        ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.6)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.6, Build version 11E708
        • CocoaPods version 1.9.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [!] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 47.1.4
        • Dart plugin version 202.6397.47
    
    [✓] Connected device (5 available)
        • Redmi 5 Plus (mobile)               • 0258ff700005                         • android-arm64  • Android 8.1.0 (API 27)
        • iPhone SE (2nd generation) (mobile) • 1119074E-0493-4533-9212-6758A33EB40C • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
        • macOS (desktop)                     • macos                                • darwin-x64     • Mac OS X 10.15.6 19G73
        • Web Server (web)                    • web-server                           • web-javascript • Flutter Tools
        • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 84.0.4147.105
    
    ! Doctor found issues in 2 categories.
    Process finished with exit code 0
    
  2. added
    f: gesturesflutter/packages/flutter/gestures repository.
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    on Aug 5, 2020
  3. goderbauer commented on Aug 5, 2020

    @goderbauer
    Member
  4. github-actions commented on Aug 18, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: gesturesflutter/packages/flutter/gestures repository.found in release: 1.17Found to occur in 1.17found in release: 1.21Found to occur in 1.21frameworkflutter/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