off method
Removes all handlers for the specified hub method.
Implementation
void off(String methodName, {MethodInvocationFunc? method}) {
if (methodName.isEmpty) {
return;
}
methodName = methodName.toLowerCase();
final List<void Function(List<dynamic>)>? handlers = _methods[methodName];
if (handlers == null) {
return;
}
if (method != null) {
final removeIdx = handlers.indexOf(method);
if (removeIdx != -1) {
handlers.removeAt(removeIdx);
if (handlers.isEmpty) {
_methods.remove(methodName);
}
}
} else {
_methods.remove(methodName);
}
}