onCreate method Null safety

  1. @override
void onCreate()
override

Implementation

@override
void onCreate() {
  super.onCreate();
  if (!_onCreated) {
    _onCreated = true;
    messages?.listen((event) {
      TypedEvent<JanusEvent> typedEvent = TypedEvent<JanusEvent>(event: JanusEvent.fromJson(event.event), jsep: event.jsep);
      print(typedEvent.event.plugindata?.data);
      if (typedEvent.event.plugindata?.data["audiobridge"] == "joined") {
        print('hell');
        typedEvent.event.plugindata?.data = AudioBridgeJoinedEvent.fromJson(typedEvent.event.plugindata?.data);
        _typedMessagesSink?.add(typedEvent);
      } else if (typedEvent.event.plugindata?.data["audiobridge"] == "event" && typedEvent.event.plugindata?.data["participants"] != null) {
        typedEvent.event.plugindata?.data = AudioBridgeNewParticipantsEvent.fromJson(typedEvent.event.plugindata?.data);
        _typedMessagesSink?.add(typedEvent);
      } else if (typedEvent.event.plugindata?.data["audiobridge"] == "event" && typedEvent.event.plugindata?.data["result"] == "ok") {
        typedEvent.event.plugindata?.data = AudioBridgeConfiguredEvent.fromJson(typedEvent.event.plugindata?.data);
        _typedMessagesSink?.add(typedEvent);
      } else if (typedEvent.event.plugindata?.data["audiobridge"] == "event" && typedEvent.event.plugindata?.data["leaving"] != null) {
        typedEvent.event.plugindata?.data = AudioBridgeLeavingEvent.fromJson(typedEvent.event.plugindata?.data);
        _typedMessagesSink?.add(typedEvent);
      }
    });
  }
}