Skip to content

type '(EventStateChanged) => Null' is not a subtype of type '(EventType) => void' of 'listener' #547

Open
@Gibrat-Erisov

Description

@Gibrat-Erisov

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();
              }
            });
          }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions