A more idiomatic way to handle global pointer events than adding a global route to the pointerRouter yourself. Simply wrap your widget in GlobalPointerListener, add your callbacks, and you're good to go!
Features
Listens to global pointer events, in case you don't want to manage complex OverlayEntry objects or add a global pointerRouter route yourself.
Getting started
Just wrap your widget in GlobalPointerListener and add callbacks for onPointerDown, onPointerUp, onPointerMove, and/or onPointerCancel.
Usage
Widget build(BuildContext context) {
return GlobalPointerListener(
onPointerUp: (_) => print('onPointerUp triggered!'),
child: Container(
width: 200,
height: 200,
color: Colors.red,
),
);
}
Additional information
Feel free to create a pull request if you have any suggestions or optimizations!