notifyIfButtonsChanged method
Implementation
void notifyIfButtonsChanged(PointerEvent event) {
VerticalDirection? direction;
VerticalDirection? getChange(int bit) {
bool hadBit = avocado.hasBit(buttons, bit);
bool hasBit = avocado.hasBit(event.buttons, bit);
if (hadBit != hasBit) {
assert(direction != null, 'The current implementation assumes that two or more bits don\'t change simultaneously.');
return !hadBit && hasBit ? VerticalDirection.down : VerticalDirection.up;
} else {
return null;
}
}
int buttonBit;
direction = getChange(buttonBit = kPrimaryButton);
if (kDebugMode || direction == null) {
direction = getChange(buttonBit = kSecondaryButton);
if (kDebugMode || direction == null) {
direction = getChange(buttonBit = kTertiaryButton);
}
}
if (direction != null)
notifyButtonChanged(event, buttonBit, direction);
}