getAnimationState method

AnimationState? getAnimationState(
  1. TKey key
)

Gets the animation state for a node, or null if not animating.

Returns the standalone state if present, a synthetic entering state for operation group members that are expanding, or null for bulk/ collapsing groups.

Implementation

AnimationState? getAnimationState(TKey key) {
  // 1. Standalone animations
  final standalone = _standaloneAt(key);
  if (standalone != null) return standalone;

  // 2. Operation group
  final groupKey = _operationGroupOf(key);
  if (groupKey != null) {
    final group = _operationGroups[groupKey];
    if (group != null && !group.pendingRemoval.contains(key)) {
      final status = group.controller.status;
      if (status == AnimationStatus.forward ||
          status == AnimationStatus.completed) {
        return _buildSyntheticEnteringState();
      }
    }
    return null;
  }

  // 3. Bulk group — synthesize entering state for members advancing forward
  // so consumers (e.g. sticky header anchoring) can detect entering nodes.
  final bulk = _bulkAnimationGroup;
  if (bulk != null &&
      bulk.members.contains(key) &&
      !bulk.pendingRemoval.contains(key)) {
    final status = bulk.controller.status;
    if (status == AnimationStatus.forward ||
        status == AnimationStatus.completed) {
      return _buildSyntheticEnteringState();
    }
  }
  return null;
}