Future deactivate(ComponentInstruction nextInstruction)

Called by the Router when an outlet disposes of a component's contents. This method in turn is responsible for calling the routerOnDeactivate hook of its child.

Source

Future<dynamic> deactivate(ComponentInstruction nextInstruction) {
  var next = _resolveToTrue;
  if (_componentRef != null) {
    next = this._componentRef.then((ComponentRef ref) =>
        hasLifecycleHook(hook_mod.routerOnDeactivate, ref.instance)
            ? ((ref.instance as OnDeactivate))
                .routerOnDeactivate(nextInstruction, this._currentInstruction)
            : true);
  }
  return next.then((_) {
    if (_componentRef != null) {
      var onDispose =
          this._componentRef.then((ComponentRef ref) => ref.destroy());
      this._componentRef = null;
      return onDispose;
    }
  });
}