pressed method Null safety
- LimitedState arg
override
What to do when the key is pressed.
Implementation
@override
void pressed(LimitedState arg) {
final p = _pressed;
if (p != null) {
p(arg as ActiveState);
}
// Note the downcast. LimitedState implementations need to ensure that
// this method is only called on LimitedOperation instances. As long as
// that invariant holds, this bit of covariance increases static checking,
// because it ensures that LimtedState pressed functions don't call any of
// the methods declared lower in the hierarchy (like handleCHS or, notably,
// the methods related to stack lift). This simplifies reasoning about the
// state machine, and avoids a bunch of null handleXXX methods in states
// that don't use them, but it does come at the prices of a little less
// static type safety.
//
// See ArgInputState._buttonDown and ProgramEntry._buttonDown to see how
// they robustly guarantee that the covariant relationship isn't violated.
}