controller property

TreeController<TKey, TData> get controller

Implementation

TreeController<TKey, TData> get controller => _controller;
set controller (TreeController<TKey, TData> value)

Implementation

set controller(TreeController<TKey, TData> value) {
  if (_controller == value) return;
  _controller = value;
  _sticky.controller = value;
  // Stale per-node caches keyed by the old controller's keys would
  // produce wrong geometry on the next layout — especially if the new
  // controller's structureGeneration happens to match the cached value
  // (fresh controllers start at 0). Reset everything that's keyed by
  // node and force a structure-change pass.
  _structureChanged = true;
  _lastStructureGeneration = -1;
  _lastVisibleNodeCount = 0;
  _lastTotalScrollExtent = 0.0;
  _animationsWereActive = false;
  // Nid-indexed arrays are sized against the old controller; reset to
  // empty and let [_ensureLayoutCapacity] regrow against the new one.
  _nodeOffsetsByNid = Float64List(0);
  _nodeExtentsByNid = Float64List(0);
  _inCacheRegionByNid = Uint8List(0);
  _writtenCacheRegionNids.clear();
  _sticky.reset();
  // Bulk-only fast-path caches are visible-position-indexed; any
  // structure from the old controller is meaningless under the new one.
  _bulkCumulativesValid = false;
  _bulkCumulativesCount = 0;
  _lastBulkAnimationGeneration = -1;
  _lastFrameUsedBulkCumulatives = false;
  // Do NOT clear `_children`: it is keyed by user TKey, not by the
  // controller's internal nid space, so a key shared between the old
  // and new controller (e.g. the user keeps the same node identity
  // when swapping data sources) maps to the same already-adopted
  // RenderBox. Clearing the map would orphan that box (it stays
  // adopted in the parent-child relationship but vanishes from the
  // iteration map, so paint/hit-test/visitChildren skip it), and the
  // element-side update path won't re-insert it because in-place
  // widget updates don't trigger `insertRenderObjectChild`.
  //
  // Stale entries for keys that exist only under the old controller
  // are evicted by the element manager's GC pass (scheduled from
  // `update` when the controller swaps), which calls
  // `removeRenderObjectChild` and properly drops the adopted box.
  markNeedsLayout();
}