debugHandleEvent method
- PointerEvent event,
- HitTestEntry<
HitTestTarget> entry
Implements the debugPaintPointersEnabled debugging feature.
RenderBox subclasses that implement handleEvent should call debugHandleEvent from their handleEvent method, as follows:
class RenderFoo extends RenderBox {
// ...
@override
void handleEvent(PointerEvent event, HitTestEntry entry) {
assert(debugHandleEvent(event, entry));
// ... handle the event ...
}
// ...
}
If you call this for a PointerDownEvent, make sure you also call it for the corresponding PointerUpEvent or PointerCancelEvent.
Implementation
bool debugHandleEvent(PointerEvent event, HitTestEntry entry) {
assert(() {
if (debugPaintPointersEnabled) {
if (event is PointerDownEvent) {
_debugActivePointers += 1;
} else if (event is PointerUpEvent || event is PointerCancelEvent) {
_debugActivePointers -= 1;
}
markNeedsPaint();
}
return true;
}());
return true;
}