EventMultiple<T> class Null safety

An Event from multiple sub-events. When consuming this event, if the first sub-event is not spent, it will be consumed, and the second will not. If the first sub-event is spent, the second one will be consumed.

So, if both sub-events are NOT spent, the multiple-event will have to be consumed twice to consume both sub-events.

If both sub-events are spent, the multiple-event returns null when consumed.

For example:
Event getTypedMessageEvt() {
   return EventMultiple(setTypedMessageEvt, widget.setTypedMessageEvt);


EventMultiple(Event? evt1, Event? evt2)


evt1 Event<T>
read / write
evt2 Event<T>
read / write
hashCode int
  • If two objects are equal according to the equals method, then hashcode of both must be the same. Since spent events are all equal, they should produce the same hashcode.
  • If two objects are NOT equal, hashcode may be the same or not, but it's better when they are not the same. However, events are mutable, and this could mean the hashcode of the state could be changed when an event is consumed. To avoid this, we make events always return the same hashCode.
  • read-only, inherited
    isNotSpent bool
    read-only, inherited
    isSpent bool
    read-only, override
    runtimeType Type
    A representation of the runtime type of the object.
    read-only, inherited
    state → T?
    Returns the event state.
    read-only, override


    consume() → T?
    Returns the event state and consumes the event.
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a non-existent method or property is accessed. [...]
    toString() String
    A string representation of this object. [...]


    operator ==(Object other) bool
    The StoreConnector has a distinct parameter which may be set to true. As a performance optimization, distinct:true allows the widget to be rebuilt only when the ViewModel changes. If this is not done, then every time any state in the store changes the widget will be rebuilt. [...]