How to ignore a specific pointer event in flutter desktop app? - flutter

I am using InteractiveViewer which enables the user to "drag" that widget around when panEnabled is true. The drag can happen using the mouse right-click or middle-click. However, I want to limit this only to the middle-click. So is there a widget, maybe like IgnorePointer, but which has a callback or something that gives me the key that caused the event and I return then true or false for ignoring or not ignoring accordingly?

Related

Flutter Desktop: Disable built-in keyboard actions in a listview

Flutter desktop:
I'm successfully using the RawKeyboardListener widget to use physical arrow keys and control the listview (selects items up and down). The scaffold is wrapped in it.
The problem is the listview widget itself has built in default keyboard actions on the arrow keys that also scroll up and down. These actions that are randomly triggered in the listview when they are pressed along with my custom actions handled by the RawKeyboardListener.
Does anyone know how to disable default listview keyboard actions on flutter desktop to prevent it from listening to physical keyboard input / triggering built-in actions. Cheers.

flutter how do I use the listener onPointerPanZoomUpdate?

I'm wanting to use onPointerPanZoomUpdate
on the listener widget
refer - https://api.flutter.dev/flutter/widgets/Listener-class.html
but when put this widget into my widget tree I don't get the option to use onPointerPanZoomUpdate. The documentation has it as a property, so I assumed I should be able to set it.
I was wanting to use this to get two finger panning working and to be able to tell when it was iPad interaction, which I want as two finger interaction, or if it was windows interaction. For windows I was wanting mouse interaction (i.e. one point).

Check if Flutter widget will/can get focus

In Flutter's focus system you can specify what should happen after FocusNode.unfocus is called. When I use previouslyFocusedChild it will automatically give focus to the previously focused child.
I was wondering if it is possible to get this information from a child perspective. For example: I would like to highlight the previsouslyFocusedChild to give the end-user some indication which element in the UI will get focus after performing an action. Is this possible?

How to check visibility of a Flutter widget even when covered by another

I'm trying to find a way to check the visibility of a Flutter widget when it's either off screen or when it's obscured by another, for example Drawer, Dialog or BottomSheet.
visibility_detector helps with checking whether it's on the screen or not but does not work with the second use case (known limitation).
Is there a lower lever api that I can use to check whether a widget is actually visible to the user?
My use case: I'm adding a widget to the Overlay when something external happens (similar to Tooltip but not on long press). If the user opens for example the Drawer, the widget will appear on top. I want to detect that the child is not visible and delay or cancel the action.
Do I understand your problem?
You have a widget you want to always be on top?
You want the user to interact with that widget first before doing other things?
Use design patterns to make coding easier, your users will thank you.
You can show a Dialog on-top of other widgets with the showGeneralDialog or showDialog functions. Because Dialogs are a design-pattern used in many apps, users will already know how to use them.
Define app behavior with explicit state.
It is too hard to derive app behavior from rendered UI, not all devices are the same size and shape. This means you should try to write a variable that describes your situation and then write the code you need to make that variable's value correct. It sounds like you want a variable like bool overlayIsShowing.

How to restrict dragging some elements in Flutter's RerderableListView

I'd like some elements in RerderableListView to be non-draggable. I know I can do nothing in the onReorder function, but I want to deny start dragging.
How to achieve that?
You can wrap the elements with AbsorbPointer or IgnorePointer.
AbsorbPointer class
A widget that absorbs pointers during hit testing.
When absorbing is true, this widget prevents its subtree from
receiving pointer events by terminating hit testing at itself. It
still consumes space during layout and paints its child as usual. It
just prevents its children from being the target of located events,
because it returns true from RenderBox.hitTest.
IgnorePointer class
A widget that is invisible during hit testing.
When ignoring is true, this widget (and its subtree) is invisible to
hit testing. It still consumes space during layout and paints its
child as usual. It just cannot be the target of located events,
because it returns false from RenderBox.hitTest.
I have wrapped widgets I want to be non-draggable with GestureDetector and set empty handler onLongPress: (){}.