Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CupertinoContextMenu doesn't fully work on the web #52967

Closed
justinmc opened this issue Mar 20, 2020 · 6 comments · Fixed by #77864
Closed

CupertinoContextMenu doesn't fully work on the web #52967

justinmc opened this issue Mar 20, 2020 · 6 comments · Fixed by #77864
Labels
f: cupertino flutter/packages/flutter/cupertino repository found in release: 1.22 Found to occur in 1.22 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P3 Issues that are less important to the Flutter project platform-web Web applications specifically

Comments

@justinmc
Copy link
Contributor

justinmc commented Mar 20, 2020

CupertinoContextMenu uses the ShaderMask widget, which currently isn't supported on web. So, when a CupertinoContextMenu is used on the web, an obscure error is thrown. The docs for CupertinoContextMenu has a broken dartpad example because of this problem.

Update: CupertinoContextMenu is usable on web now, but it is missing the small darkening/lightening effect on the target before the menu opens. Fixing that depends on #44152.

@justinmc justinmc added f: cupertino flutter/packages/flutter/cupertino repository platform-web Web applications specifically labels Mar 20, 2020
@justinmc justinmc self-assigned this Mar 20, 2020
@justinmc
Copy link
Contributor Author

#52977 will get CupertinoContextMenu working without using ShaderMask, so not completely on par with other platforms. This issue shouldn't be considered closed until web supports ShaderMask (#44152) and the special casing for web added in the PR above have been removed.

@justinmc justinmc removed their assignment Mar 23, 2020
@yjbanov yjbanov added this to the Goals milestone Mar 26, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@yjbanov yjbanov added P3 Issues that are less important to the Flutter project and removed P2 Important issues not at the top of the work list labels Jun 16, 2020
@TahaTesser TahaTesser added the framework flutter/packages/flutter repository. See also f: labels. label Jun 21, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@TahaTesser
Copy link
Member

Hi @justinmc
Looks like CupertinoContextMenu is working on web now, also working on dartpad

ezgif com-resize

code sample
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      theme: ThemeData.dark(),
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Material App Bar'),
      ),
      body: Center(
        child: CupertinoContextMenu(
          child: Container(
            color: Colors.red,
            width: 100,
            height: 100,
            alignment: Alignment.center,
            child: Material(
              color: Colors.red,
              child: Text(
                'Long Press here',
                textAlign: TextAlign.center,
              ),
            ),
            margin: const EdgeInsets.all(16),
          ),
          actions: <Widget>[
            CupertinoContextMenuAction(
              child: const Text('Action one'),
              onPressed: () {
                Navigator.pop(context);
              },
            ),
            CupertinoContextMenuAction(
              child: const Text('Action two'),
              onPressed: () {
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {},
      ),
    );
  }
}
flutter doctor -v
[✓] Flutter (Channel master, 1.22.0-2.0.pre.162, on Mac OS X 10.15.6 19G2021,
    locale en-GB)
    • Flutter version 1.22.0-2.0.pre.162 at
      /Users/tahatesser/Code/flutter_master
    • Framework revision bcfad2068e (77 minutes ago), 2020-09-01 08:34:25 -0400
    • Engine revision 165abef0a2
    • Dart version 2.10.0 (build 2.10.0-77.0.dev)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • 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)
    • All Android licenses accepted.

[✓] 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 version 48.1.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (4 available)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E • ios            • iOS 13.6.1
    • macOS (desktop)        • macos                     • darwin-x64     • Mac OS X 10.15.6
      19G2021
    • Web Server (web)       • web-server                • web-javascript • Flutter Tools
    • Chrome (web)           • chrome                    • web-javascript • Google Chrome
      84.0.4147.135

• No issues found!

@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 1, 2020
@justinmc
Copy link
Contributor Author

justinmc commented Sep 1, 2020

It's still missing the small ShaderMask effect because it's not supported on the web. In your gif, the red square should darken really quickly before the menu opens.

// TODO(justinmc): When ShaderMask is supported on web, remove this
// conditional and use ShaderMask everywhere.
// https://github.com/flutter/flutter/issues/52967.
child: kIsWeb
? Container(key: _childGlobalKey, child: widget.child)
: ShaderMask(

I'll edit the title and description a bit to make it more obvious what's left to do for this issue.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 1, 2020
@justinmc justinmc changed the title CupertinoContextMenu doesn't work on the web CupertinoContextMenu doesn't fully work on the web Sep 1, 2020
@TahaTesser TahaTesser added found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on labels Sep 2, 2020
@ferhatb
Copy link
Contributor

ferhatb commented Feb 25, 2021

@justinmc , shadermask has now landed in master. You should be able to remove kIsWeb from framework and close this issue.

@justinmc
Copy link
Contributor Author

Awesome news! Here's the PR: #77864

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: cupertino flutter/packages/flutter/cupertino repository found in release: 1.22 Found to occur in 1.22 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P3 Issues that are less important to the Flutter project platform-web Web applications specifically
Projects
Development

Successfully merging a pull request may close this issue.

6 participants