Open
Description
Describe the bug
Fix type '(EventStateChanged) => Null' is not a subtype of type '(EventType) => void' of 'listener
Description:
When subscribing to EventStateChanged via server_transaction.on(), Dart throws a type error because the callback's return type is implicitly Null instead of void. This happens due to type inference issues with dynamic and generic methods.
https://github.com/flutter-webrtc/dart-sip-ua/blob/main/lib/src/rtc_session.dart#L835
Affected Code:
final dynamic handlers = _request.server_transaction;
if (handlers is EventManager) {
handlers.on(EventStateChanged(), (EventStateChanged state) {
logger.d('EventStateChanged received');
if (_request.server_transaction.state ==
TransactionState.TERMINATED) {
sendRequest(SipMethod.BYE, <String, dynamic>{
'extraHeaders': extraHeaders,
'body': body
});
dialog.terminate();
}
});
}