consumeFrom<T> static method

T? consumeFrom<T>(
  1. Event<T> evt1,
  2. Event<T> evt2
)

This is a convenience method to consume from more than one event. If the first event is not spent, it will be consumed, and the second will not. If the first event is spent, the second one will be consumed. So, if both events are NOT spent, the method will have to be called twice to consume both. If both are spent, returns null.

For example:
String getTypedMessageEvt() {
   return Event.consumeFrom(setTypedMessageEvt, widget.setTypedMessageEvt);
 }

Implementation

static T? consumeFrom<T>(Event<T> evt1, Event<T> evt2) {
  T? evt = evt1.consume();
  evt ??= evt2.consume();
  return evt;
}