didAddToChannel method Null safety

void didAddToChannel()

Lifecycle callback, invoked after added to channel, but before any requests are served.

Subclasses override this method to provide final, one-time initialization after it has been added to a channel, but before any requests are served. This is useful for performing any caching or optimizations for this instance. For example, Router overrides this method to optimize its list of routes into a more efficient data structure.

This method is invoked immediately after ApplicationChannel.entryPoint is completes, for each instance in the channel created by ApplicationChannel.entryPoint. This method will only be called once per instance.

Controllers added to the channel via link may use this method, but any values this method stores must be stored in a static structure, not the instance itself, since that instance will only be used to handle one request before it is garbage collected.

If you override this method you should call the superclass' implementation so that linked controllers invoke this same method. If you do not invoke the superclass' implementation, you must ensure that any linked controllers invoked this method through other means.

Implementation

void didAddToChannel() {
  _nextController?.didAddToChannel();
}