flutter-webrtc / dart-sip-ua

A dart-lang version of the SIP UA stack.
MIT License
339 stars 269 forks source link

Use more descriptive types instead of dynamic maps. #497

Open VictorUvarov opened 2 weeks ago

VictorUvarov commented 2 weeks ago

Is your feature request related to a problem? Please describe. All the methods that expect a Map<String,dynamic> are error prone and are a bad user experience. Not to mention maintaining the library is much more difficult.

Describe the solution you'd like I would like to see the library make a breaking change in the name of type safety, so that the caller of the method knows exactly the options they have.

Describe alternatives you've considered Keep using the library as is, but it makes it harder to maintain.

Additional context Example change

void hangup([Map<String, dynamic>? options])

changes to

void hangup([TerminateOptions? options])

this improves the readability of the library code

terminate(<String, dynamic>{
        'status_code': 500,
        'reason_phrase': DartSIP_C.CausesType.CONNECTION_ERROR,
        'cause': DartSIP_C.CausesType.CONNECTION_ERROR
      });

to this

final TerminateOptions options = TerminateOptions()
        ..statusCode = 500
        ..reasonPhrase = DartSIP_C.CausesType.CONNECTION_ERROR
        ..cause = DartSIP_C.CausesType.CONNECTION_ERROR;
terminate(options);