Skip to content

Cupertino ContextMenu improved onTap support #81057

Description

@cpboyd

Use case

Many of the native iOS apps that support the CupertinoContextMenu use it on items that already have an existing onTap implementation.

Proposal

Currently, CupertinoContextMenu can trigger while also triggering onTap of the child element (depending on the exact duration of the tap) so it'd be nice to rework this such that a single GestureDetector is controlling both.

Activity

  1. added
    in triagePresently being triaged by the triage team
    p: cupertino_uicupertino_ui package in flutter/packages
    f: gesturesflutter/packages/flutter/gestures repository.
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    c: new featureNothing broken; request for a new capability
    and removed
    in triagePresently being triaged by the triage team
    on Apr 26, 2021
  2. umbrellait-andrey-sosnovyy commented on Aug 25, 2022

    @umbrellait-andrey-sosnovyy

    same issue #70716

  3. thipokch commented on Nov 7, 2022

    @thipokch

    @cpboyd Did you come up with any workaround? I calling a package with a native iOS implementation, but it's very complicated.

  4. Piinks commented on May 21, 2025

    @Piinks
    Contributor

    It looks like this was resolved by #131030. If this issue is still present, please file a new one with updated reproduction steps. Thank you!

  5. LorTos commented on May 26, 2025

    @LorTos

    This issue is still present, it is really evident when pushing a route because the overlay entry stays on top of the new route. To reproduce you have to hold the tap for a bit too long, but not long enough to trigger the context menu, see the third "tap" in the video.

    Screen.Recording.2025-05-26.at.21.28.48.mov

    Here is a sample code to reproduce this issue:

    import 'package:flutter/cupertino.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        final colorScheme = ColorScheme.fromSeed(seedColor: Colors.orange);
        return MaterialApp(
          theme: ThemeData(
            colorScheme: colorScheme,
            appBarTheme: AppBarTheme(backgroundColor: colorScheme.secondaryContainer),
          ),
          home: const HomePage(),
        );
      }
    }
    
    class HomePage extends StatelessWidget {
      const HomePage({super.key});
    
      @override
      Widget build(BuildContext context) => Scaffold(
            appBar: AppBar(
              title: Text('Home'),
            ),
            body: Center(
              child: CupertinoContextMenu(
                actions: [
                  CupertinoContextMenuAction(
                    child: Text('Test'),
                  ),
                ],
                child: GestureDetector(
                  onTap: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(builder: (context) => _OtherPage()),
                    );
                  },
                  child: Container(
                    color: Colors.orange,
                    height: 100,
                    width: 100,
                  ),
                ),
              ),
            ),
          );
    }
    
    class _OtherPage extends StatelessWidget {
      const _OtherPage({super.key});
    
      @override
      Widget build(BuildContext context) => Scaffold(
            appBar: AppBar(
              title: Text('Other'),
            ),
          );
    }
  6. Piinks commented on May 29, 2025

    @Piinks
    Contributor

    @LorTos please file a new issue with this reproduction and the output of flutter doctor.

  7. LorTos commented on Jun 3, 2025

    @LorTos
  8. github-actions commented on Jun 17, 2025

    @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.

  9. locked as resolved and limited conversation to collaborators on Jun 17, 2025
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

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packagesteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions