addDispatcher static method
void
addDispatcher(})
override
Ensures a MultiDragScaleDispatcher is registered on the game that owns
component, then enables drag and/or scale as requested.
For a component that mixes both DragCallbacks and ScaleCallbacks,
this method is called twice from their separate onMount chains, once
with hasDrag=true and once with hasScale=true. The second call finds
the existing dispatcher and simply enables the remaining flag.
Implementation
static void addDispatcher(
Component component, {
required bool hasDrag,
required bool hasScale,
}) {
final game = component.findRootGame()!;
var dispatcher =
game.findByKey(const MultiDragScaleDispatcherKey())
as MultiDragScaleDispatcher?;
if (dispatcher == null) {
dispatcher = MultiDragScaleDispatcher();
game.registerKey(const MultiDragScaleDispatcherKey(), dispatcher);
game.add(dispatcher);
}
if (hasDrag) {
dispatcher.enableDrag();
}
if (hasScale) {
dispatcher.enableScale();
}
}