unlisten method

  1. @override
Future<void> unlisten(
  1. String eventName
)
override

Stops listening to a specific event.

Throws SocketNotConnectedException if not connected. Throws SocketEventException if unlisten fails.

Implementation

@override
Future<void> unlisten(String eventName) async {
  try {
    if (eventName.isEmpty) {
      throw SocketEventException('Event name cannot be empty');
    }

    await methodChannel.invokeMethod('unlisten', {'event': eventName});
  } on PlatformException catch (e) {
    _handlePlatformException(e, 'unlisten');
  } catch (e) {
    if (e is SocketException) {
      rethrow;
    }
    throw SocketEventException('Unexpected error while unlistening from event "$eventName": $e');
  }
}