gskinnerteam / flutter-context-menu Goto Github PK
View Code? Open in Web Editor NEWA package to show context menus on right-click or long-press.
License: MIT License
A package to show context menus on right-click or long-press.
License: MIT License
Readme documentation says:
To get started, wrap a ContextMenuOverlay around your top-most view or app:
return ContextMenuOverlay(
child: MaterialApp(...)
);
But this is giving some no directional widget found error. In the ContextMenuOverlay
class documentation the docs are right, pointing that it should be placed somewhere in between MaterialApp
and the top-most view.
It would be nice to be able to add dividers (PopupMenuDivider) like in PopupMenuButton
Hi, some times I get this error while trying to show the menu:
======== Exception caught by gesture ===============================================================
The following _CastError was thrown while handling a gesture:
type 'Null' is not a subtype of type '_InheritedContextMenu' in type cast
When the exception was thrown, this was the stack:
#0 ContextMenuOverlay.of (package:context_menus/src/context_menu_overlay.dart:43:76)
#1 ContextMenuExtensions.contextMenuOverlay (package:context_menus/context_menus.dart:20:72)
#2 ContextMenuRegion.build.showMenu (package:context_menus/src/context_menu_region.dart:19:15)
#3 TapGestureRecognizer.handleTapUp.<anonymous closure> (package:flutter/src/gestures/tap.dart:619:71)
#4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24)
#5 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:619:11)
#6 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:298:5)
#7 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:232:7)
#8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:563:9)
#9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:94:12)
#10 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:139:9)
#11 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#12 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:137:18)
#13 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:123:7)
#14 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:445:19)
#15 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:425:22)
#16 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:329:11)
#17 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:380:7)
#18 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:344:5)
#19 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:302:7)
#20 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:285:7)
#24 _invoke1 (dart:ui/hooks.dart:170:10)
#25 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7)
#26 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
(elided 3 frames from dart:async)
Handler: "onSecondaryTap"
Recognizer: TapGestureRecognizer#e9365
debugOwner: GestureDetector
state: ready
My code:
child: ContextMenuRegion(
contextMenu: GenericContextMenu(
buttonConfigs: [
ContextMenuButtonConfig(
"Button 1",
onPressed: () => _copyCode(),
),
ContextMenuButtonConfig(
"Button 2",
onPressed: () => _copyCode(),
),
ContextMenuButtonConfig(
"Button 3",
onPressed: () => _copyCode(),
),
],
),
child: ListTile(...))
Is there a known issue?
Hello, thanks for this package that I am exploring !
Tried a basic text adding menu to item on a columns
When a context menu is open and I right click another entries,
instead of opening a new context and closing the previous one,
it first close the first menu then another clic is required to open a new context.
Still exploring this package maybe I miss a parameter.
Cheers
When using GenericContextMenu, if I click on one of the ContextMenuButtonConfig's, is there a way to popup a new custom windows with
context.contextMenuOverlay.show()
Hello! The current version of this package on pub.dev is 0.1.0+6
, but pubspec.yaml file in this repo shows 0.0.1+1
. I was hoping to see recent commits to the package on GitHub, but it like the repo has not been updated with the changes that were published to pub.dev.
Is there a way to run an action (maybe asynchronously) before the context menu appears (like causing a list item to be appear selected)?
Right now the context menu blocks all state updates till after it has been dismissed.
the right button displays the browser context menu
It would be very helpful to see some screenshots, to see what the widgets look like.
The link of this repo is https://github.com/gskinnerTeam/flutter-context-menus. But on pub.dev is a wrong link: https://pub.dev/packages/custom_pop_up_menu
As you can see in the following screenshot, the icon in the context menu is not aligned with the text:
I suspect this is because the Row
that builds the menu item is not setting its crossAxisAlignment
properly.
The example shows:
return ContextMenuOverlay(
child: MaterialApp(...)
);
but when actually creating such a layout with this code:
import 'package:flutter/material.dart';
import 'package:context_menus/context_menus.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ContextMenuOverlay(child: MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: Text("Test"),
),
body: Column(children: [],),
),
));
}
}
I get this error:
======== Exception caught by widgets library =======================================================
The following assertion was thrown building _InheritedContextMenu:
No MediaQuery widget ancestor found.
Scaffold widgets require a MediaQuery widget ancestor.
The specific widget that could not find a MediaQuery ancestor was: Scaffold
dirty
state: ScaffoldState#48e24(lifecycle state: initialized, tickers: tracking 2 tickers)
The ownership chain for the affected widget is: "Scaffold ← _InheritedContextMenu ← LayoutBuilder ← ContextMenuOverlay ← MyApp ← [root]"
No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of(). This can happen because you have not added a WidgetsApp, CupertinoApp, or MaterialApp widget (those widgets introduce a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.
The relevant error-causing widget was:
_InheritedContextMenu file:///C:/Users/Zarai/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/context_menus-0.1.0+5/lib/src/context_menu_overlay.dart:73:16
When the exception was thrown, this was the stack:
#0 debugCheckHasMediaQuery.<anonymous closure> (package:flutter/src/widgets/debug.dart:219:7)
#1 debugCheckHasMediaQuery (package:flutter/src/widgets/debug.dart:234:4)
#2 MediaQuery.of (package:flutter/src/widgets/media_query.dart:820:12)
#3 ScaffoldState.didChangeDependencies (package:flutter/src/material/scaffold.dart:2831:50)
#4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4732:11)
...
====================================================================================================
which doesn't happen when the ContextMenuOverlay
is inside MaterialApp
.
Navigator.pop(context);
would close the context menu, but this does not seem to be the case.cardBuilder
of ContextMenuOverlay
does not seem to work. (It is to note, that my ContextMenuOverlay
is placed under the MaterialApp as of #4.Regarding 1, here is an explanation video:
Hi,
It would be great if it was possible to show the context menu on regular tap in addition to secondary tap and long press.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.