addWithAxisOffset method Null safety
Transforms mainAxisPosition
and crossAxisPosition
to the local
coordinate system of a child for hit-testing the child.
The actual hit testing of the child needs to be implemented in the
provided hitTest
callback, which is invoked with the transformed
position
as argument.
For the transform mainAxisOffset
is subtracted from mainAxisPosition
and crossAxisOffset
is subtracted from crossAxisPosition
.
The paintOffset
describes how the paint position of a point painted at
the provided mainAxisPosition
and crossAxisPosition
would change after
mainAxisOffset
and crossAxisOffset
have been applied. This
paintOffset
is used to properly convert PointerEvents to the local
coordinate system of the event receiver.
The paintOffset
may be null if mainAxisOffset
and crossAxisOffset
are
both zero.
The function returns the return value of hitTest
.
Implementation
bool addWithAxisOffset({
required Offset? paintOffset,
required double mainAxisOffset,
required double crossAxisOffset,
required double mainAxisPosition,
required double crossAxisPosition,
required SliverHitTest hitTest,
}) {
assert(mainAxisOffset != null);
assert(crossAxisOffset != null);
assert(mainAxisPosition != null);
assert(crossAxisPosition != null);
assert(hitTest != null);
if (paintOffset != null) {
pushOffset(-paintOffset);
}
final bool isHit = hitTest(
this,
mainAxisPosition: mainAxisPosition - mainAxisOffset,
crossAxisPosition: crossAxisPosition - crossAxisOffset,
);
if (paintOffset != null) {
popTransform();
}
return isHit;
}