hitTest method

bool hitTest(
  1. HitTestResult result,
  2. int x,
  3. int y
)

Adds what is at x, y of this object, a cell in its own coordinates, to result: nothing when the cell is outside its bounds (a child that sticks out of its parent is cut off there, as paint cuts it); otherwise the children hit there (hitTestChildren), then this object when it is hit there itself (hitTestSelf), a child is, or it is HitTestBehavior.translucent. Returns whether it is hit: then what it covers is not tested. An object that shows an error (debugError) is hit anywhere in its bounds, and its children not tested. Uses the last layout; allocates nothing.

Implementation

bool hitTest(HitTestResult result, int x, int y) {
  if (x < 0 || y < 0 || x >= width || y >= height) {
    return false;
  }
  if (_errorShown != _shownNot) {
    result.add(this, x, y);
    return true;
  }
  final hit = hitTestChildren(result, x, y) || hitTestSelf(x, y);
  if (hit || hitTestBehavior == HitTestBehavior.translucent) {
    result.add(this, x, y);
  }
  return hit;
}