Search code examples
flutterwebrtcsimplewebrtcwebrtc-androidopenwebrtc

Flutter WebRTC camera doesn't show up


I'm working on WebRTC for video calling in Flutter. Everything is working like charm, but when I run the app it does not show the camera both local camera and remote (Camera Permission is given), but if I hot reload the app the camera shows.

This is my code.

enter image description here

Here is my UI.

Expanded(
    child: Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Expanded(child: RTCVideoView(_localRenderer, mirror: true)),
          Expanded(child: RTCVideoView(_remoteRenderer)),
        ],
      ),
    ),
),`

Solution

  • Try adding a setState after calling the getUserMedia() function. I'll show you my example.

    ElevatedButton(
                onPressed: () async {
                  await signaling.openUserMedia(_localRenderer, _remoteRenderer);
                  setState(() {});
                  print("Open Camera");
                },
                child: const Text("Open camera & microphone"),
              ),