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
Comments
Hi @justinmc code sampleimport '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
|
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. flutter/packages/flutter/lib/src/cupertino/context_menu.dart Lines 517 to 522 in e82571a
I'll edit the title and description a bit to make it more obvious what's left to do for this issue. |
@justinmc , shadermask has now landed in master. You should be able to remove kIsWeb from framework and close this issue. |
Awesome news! Here's the PR: #77864 |
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 |
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.
The text was updated successfully, but these errors were encountered: