Preparation
- You have to use
StatefulWidget
orHookWidget
- You can implement it without any event conflicts by using
Listener
widget.
SourceCode
I will intraduce it by using flutter_fooks
Define State
Define cursorIcon
state inside a build
method.
final cursorIcon = useState<SystemMouseCursor>(SystemMouseCursors.grab);
Wrap your widget by Listener
- Wrap your widget by
Listener
. - Also wrap your widget by
MouseRegion
.child: Listener( onPointerDown: (_){ debugPrint("down"); cursorIcon.value = SystemMouseCursors.grabbing; }, onPointerUp: (_){ debugPrint("up"); cursorIcon.value = SystemMouseCursors.grab; }, child: MouseRegion( cursor: cursorIcon.value,
If you want to use another cursor icons , you can change SystemMouseCursors.XXXX
.
コメント