dispose method
Removes all instance's events
Implementation
void dispose(Object? instance) {
/// instanceKey with a dot, to prevent another event containing
/// the same starts number of the instanceKey from being removed.
///
/// _events = {
/// "6778923.4576": [...],
/// "67789.4523": [...],
/// ...
/// };
/// instanceKey = "67789"; <- This could remove another event, it is not expected.
/// instanceKeyWithDot = "67789."; <- This remove event correctly.
final instanceKeyWithDot = "${_getInstanceKey(instance)}.";
_events.removeWhere(
(key, value) => key.startsWith(instanceKeyWithDot),
);
_oneCallbacks.removeWhere(
(key, value) => key.startsWith(instanceKeyWithDot),
);
if (instance is ReactterNotifyManager) {
instance._removeAllListeners();
}
}