consumeViewAttached method

  1. @protected
bool consumeViewAttached()

For platform adapters: atomically check-and-clear the view-attached flag.

Returns true exactly once per attach — the first detachView() after a view attaches gets true and should run its per-view cleanup; a redundant second call returns false and must skip it. This keeps detach cleanup idempotent when detachView() is invoked twice during one teardown — the federated platform view detaches the adapter, and an owning NutrientDocumentView then disposes it (and dispose also detaches). Returns false when no view ever attached, so disposing a never-shown adapter does no per-view work.

Implementation

@protected
bool consumeViewAttached() {
  if (!_viewAttached) return false;
  _viewAttached = false;
  return true;
}