1

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)),
        ],
      ),
    ),
),`

1 Answers1

6

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"),
          ),
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77