FloatyActionRouter class final

A typed action dispatch system that replaces manual string-key matching.

Define an ActionKey as a static const on each action class, then register handlers by passing the key. The type parameter ensures the handler is invoked with the correct payload type.

Main app side:

final router = FloatyActionRouter();

router.on(
  NavigateAction.key,
  (action) => mapController.move(action.target, zoom),
);

// Dispatch an action to the overlay.
router.dispatch(PinAction(lat: 12.0, lng: -86.0));

Overlay side:

final router = FloatyActionRouter.overlay();

router.on(
  PinAction.key,
  (action) => setState(() => pin = action),
);

Actions coexist with raw shareData messages — they use a reserved _floaty_action prefix and do not interfere with existing data streams.

Offline queueing (overlay only):

When the main app is disconnected, dispatched actions are queued and automatically flushed upon reconnection. Control queue behavior with maxQueueSize and overflowStrategy.

Constructors

FloatyActionRouter({int maxQueueSize = 100, QueueOverflowStrategy overflowStrategy = QueueOverflowStrategy.dropOldest})
Creates an action router for the main app side.
FloatyActionRouter.overlay({int maxQueueSize = 100, QueueOverflowStrategy overflowStrategy = QueueOverflowStrategy.dropOldest})
Creates an action router for the overlay side.

Properties

hashCode int
The hash code for this object.
no setterinherited
maxQueueSize int
Maximum number of actions to queue while disconnected.
final
overflowStrategy QueueOverflowStrategy
Strategy for handling queue overflow.
final
queueLength int
The number of actions currently queued (waiting for reconnection).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispatch(FloatyAction action) Future<void>
Dispatches an action to the other side (main app or overlay).
dispose() Future<void>
Releases resources and unregisters the channel handler.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
off<A extends FloatyAction>(ActionKey<A> key) → void
Removes the handler associated with key.
on<A extends FloatyAction>(ActionKey<A> key, FutureOr<void> handler(A action)) → void
Registers a handler for the action class identified by key.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited