DeepLinkCommandRouter class
Parses deep links into typed DeepLinkCommands and dispatches them to
registered handlers — no concrete deep-link plugin dependency (app_links,
uni_links, ...); a consuming app feeds its own URI stream into
handleUri.
Not-ready queue: a link arriving before markReady is called is queued (never dropped, never dispatched early) and drained exactly once when markReady runs — a duplicate arriving twice before ready is only queued once.
Dedup: the same URI arriving again within dedupeCooldown of its last dispatch is ignored — covers both the same-process double-delivery some platforms do on relaunch and 2 concurrent calls for the same link (the cooldown timestamp is stamped synchronously before any handler awaits, so 2 back-to-back calls resolve deterministically: the first dispatches, the second is deduped).
Handler isolation: every registered handler for a command type runs (highest registerHandler priority first) even if an earlier one throws — a throw is captured into that entry's DeepLinkHandlerResult, never rethrown, and never affects a different command's dispatch.
- Inheritance
-
- Object
- GetLifeCycle
- DisposableInterface
- GetxService
- DeepLinkCommandRouter
Constructors
-
DeepLinkCommandRouter({required List<
DeepLinkRoute> routes, Duration dedupeCooldown = const Duration(seconds: 3), int maxUriLength = 2048})
Properties
- dedupeCooldown → Duration
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialized → bool
-
Checks whether the controller has already been initialized.
no setterinherited
- isClosed → bool
-
Checks whether the controller has already been closed.
no setterinherited
- maxUriLength → int
-
final
-
onDelete
→ InternalFinalCallback<
void> -
Internal callback that starts the cycle of this controller.
finalinherited
-
onStart
→ InternalFinalCallback<
void> -
Called at the exact moment the widget is allocated in memory.
It uses an internal "callable" type, to avoid any @overrides in subclases.
This method should be internal and is required to define the
lifetime cycle of the subclass.
finalinherited
-
routes
→ List<
DeepLinkRoute> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
$configureLifeCycle(
) → void -
inherited
-
handlerCountFor(
String commandType) → int -
Number of handlers currently registered for
commandType— a testing seam for proving aregisterHandler/unregisterHandlerpair (e.g. in aState'sinitState/dispose) doesn't leak an orphaned handler. -
handleUri(
Uri uri) → Future< DeepLinkHandleResult> -
markReady(
) → void - Marks the router ready to dispatch — drains every link queued while not ready, each exactly once. A second call is a no-op.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onClose(
) → void -
Called before
onDeletemethod.onClosemight be used to dispose resources used by the controller. Like closing events, or streams before the controller is destroyed. Or dispose objects that can potentially create some memory leaks, like TextEditingControllers, AnimationControllers. Might be useful as well to persist some data on disk.inherited -
onInit(
) → void -
Called immediately after the widget is allocated in memory.
You might use this to initialize something for the controller.
inherited
-
onReady(
) → void -
Called 1 frame after onInit(). It is the perfect place to enter
navigation events, like snackbar, dialogs, or a new route, or
async request.
inherited
-
registerHandler(
String commandType, DeepLinkHandler handler, {int priority = 0}) → void -
toString(
) → String -
A string representation of this object.
inherited
-
unregisterHandler(
String commandType, DeepLinkHandler handler) → void -
Removes the specific
handlerpreviously registered forcommandTypevia registerHandler (matched by function identity) — a no-op if it was never registered, or was already removed. This router is aGet.put(..., permanent: true)singleton that outlives any single screen (see class doc), so a caller registering from aState.initState(e.g. a closure that callssetState) must unregister the SAME handler indispose(), or it stays reachable — and gets invoked on a future deep link — forever after that State unmounts. Other handlers registered for the SAMEcommandType(this router supports more than one per type, dispatched by priority) are left untouched.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- maybe → DeepLinkCommandRouter?
-
no setter