register method
Register a hook and return its ID.
The hook is added to the chain for its HookRegistration.type and sorted by priority.
Implementation
String register(HookRegistration registration) {
if (_registrationsById.containsKey(registration.id)) {
throw StateError(
'Hook with id "${registration.id}" is already registered. '
'Unregister it first or use a different id.',
);
}
final chain = _chains.putIfAbsent(
registration.type,
() => HookChain(type: registration.type),
);
chain.add(registration);
_registrationsById[registration.id] = registration;
return registration.id;
}