makeLiveCancellable method

Cancellable makeLiveCancellable({
  1. Cancellable? other,
  2. bool weakRef = false,
})

构建一个绑定到lifecycleCancellable *weakRef 是否是弱引用的 保持兼容性为 false 将在3.0版本改为 true

Implementation

Cancellable makeLiveCancellable({Cancellable? other, bool weakRef = false}) {
  assert(currentLifecycleState > LifecycleState.destroyed,
      'Must be used before destroyed.');
  if (currentLifecycleState <= LifecycleState.destroyed) {
    return Cancellable()..cancel();
  }
  return _map
      .putIfAbsent(this, () => _LiveCancellableManagerObserver(this))
      ._makeCancellableForLive(other, weakRef);
}