addSingleExecutionListener method
Registers a listener that will be called only once when the object notifies its listeners. After the listener is called, it is automatically removed.
Implementation
void addSingleExecutionListener(VoidCallback listener) {
// This is a special case that requires a strong reference to the temporary
// wrapper closure. We hold it until it's called.
late final VoidCallback tempListener;
tempListener = () {
try {
listener();
} finally {
removeListener(tempListener);
}
};
addStrongRefListener(strongRefListener: tempListener);
}