- override
Tests whether the given point, on a rectangle of a given size, would be considered to hit the decoration or not. For example, if the decoration only draws a circle, this function might return true if the point was inside the circle and false otherwise.
Source
@override bool hitTest(Size size, Point position) { assert(shape != null); assert((Point.origin & size).contains(position)); switch (shape) { case BoxShape.rectangle: if (borderRadius != null) { RRect bounds = borderRadius.toRRect(Point.origin & size); return bounds.contains(position); } return true; case BoxShape.circle: // Circles are inscribed into our smallest dimension. Point center = size.center(Point.origin); double distance = (position - center).distance; return distance <= math.min(size.width, size.height) / 2.0; } assert(shape != null); return null; }