registerWith static method

void registerWith(
  1. Registrar registrar
)

Implementation

static void registerWith(Registrar registrar) {
  final methodChannel = MethodChannel(
    'agora_rtc_engine',
    const StandardMethodCodec(),
    registrar,
  );
  final eventChannel = PluginEventChannel(
      'agora_rtc_engine/events', const StandardMethodCodec(), registrar);

  final pluginInstance = AgoraRtcEngineWeb();
  methodChannel.setMethodCallHandler(pluginInstance.handleMethodCall);
  eventChannel.setController(pluginInstance._controllerEngine);

  MethodChannel(
    'agora_rtc_channel',
    const StandardMethodCodec(),
    registrar,
  ).setMethodCallHandler(pluginInstance.handleChannelMethodCall);
  PluginEventChannel(
          'agora_rtc_channel/events', const StandardMethodCodec(), registrar)
      .setController(pluginInstance._controllerChannel);

  MethodChannel(
    'agora_rtc_audio_device_manager',
    const StandardMethodCodec(),
    registrar,
  ).setMethodCallHandler(pluginInstance.handleADMMethodCall);

  MethodChannel(
    'agora_rtc_video_device_manager',
    const StandardMethodCodec(),
    registrar,
  ).setMethodCallHandler(pluginInstance.handleVDMMethodCall);

  // ignore: undefined_prefixed_name
  ui.platformViewRegistry.registerViewFactory('AgoraSurfaceView',
      (int viewId) {
    var element = DivElement();
    MethodChannel('agora_rtc_engine/surface_view_$viewId',
            const StandardMethodCodec(), registrar)
        .setMethodCallHandler(
            (call) => pluginInstance.handleViewMethodCall(call, element));
    return element;
  });

  var element = ScriptElement()
    ..src =
        'assets/packages/agora_rtc_engine/assets/AgoraRtcWrapper.bundle.js'
    ..type = 'application/javascript';
  late StreamSubscription<Event> loadSubscription;
  loadSubscription = element.onLoad.listen((event) {
    loadSubscription.cancel();
    pluginInstance._engineMain = _IrisRtcEngine();
    pluginInstance._engineSub = _IrisRtcEngine();
  });
  document.body!.append(element);
}