HintTargetRegistry class

Target registry by string ids — the heart of the "no GlobalKey" model.

Policies:

  • Duplicate id: "last registration wins" + warning. ListView rebuilds create a new target instance on every layout, so "first registered" quickly goes stale.
  • Unregister by identity, not by id: unregister takes the registration object itself and only removes it if it is the current owner of the id. Disposing an old instance cannot remove a fresh one — this architecturally rules out the classic bug "dispose of the old one killed the new one".
  • Data only: the registry stores no widgets/elements — just id, link and context; no leaks.

Constructors

HintTargetRegistry({void onWarning(String warning)?})

Properties

hashCode int
The hash code for this object.
no setterinherited
ids Set<String>
All registered ids (unmodifiable copy; used for typo candidates).
no setter
onWarning ↔ void Function(String warning)?
Developer warnings (duplicate id etc.); in debug builds the controller wires up printing.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Subscribe to registry changes (registration or removal of the current owner). The controller subscribes here and translates changes into state-machine events (appeared/vanished); other subsystems can subscribe the same way. Re-subscribing the same callback is a no-op.
lookup(String id) HintTargetRegistration?
Current registration for id, or null if the target is not mounted.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(HintTargetRegistration registration) → void
removeListener(VoidCallback listener) → void
Unsubscribe; removing an unsubscribed callback is a silent no-op (dispose races are inevitable, not an error).
toString() String
A string representation of this object.
inherited
unregister(HintTargetRegistration registration) → void
Removes registration only if it is the current owner of its id. A foreign/stale registration is a silent no-op (dispose races are inevitable) and does not notify listeners.

Operators

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

Static Properties

defaultInstance HintTargetRegistry
Global instance for zero-config (HintTarget without registry:). Tests and apps with their own registries create separate instances.
final