isInteractingOf static method

bool isInteractingOf(
  1. BuildContext context, [
  2. Object? tag
])

Coarse "is the user touching the stage right now?" signal.

When tag is omitted, returns true if Stage's recognizer has any pointer down — untagged, fires for any interaction. Suitable for callers guaranteed to be mounted only while their tag is active (e.g. overlay-slot builders) or for any caller that doesn't care which origin is being touched.

When tag is provided, returns true iff tag is the active stage tag and there's at least one pointer down. The aspect is tag-scoped, so consumers in unrelated origin subtrees don't rebuild on peer-origin interactions.

Implementation

static bool isInteractingOf(BuildContext context, [Object? tag]) {
  if (tag == null) {
    return InheritedModel.inheritFrom<StageData>(context, aspect: _interactingAspect)!.interacting;
  }
  final data = InheritedModel.inheritFrom<StageData>(context, aspect: (#interacting, tag))!;
  return data.tag == tag && data.interacting;
}