Call initialize before setting the stream

I am getting this error “Call initialize before setting the stream” almost every single time when i try to connect to a call. I use the example code from Github to init/show the video track. I use “livekit_client: ^2.8.1” any ideas?

Container(

              alignment: Alignment.center,

              color: Colors.black,

              child: activeVideoTrack != null && !activeVideoTrack!.muted

                  ? VideoTrackRenderer(

                      fit: fit,

                      renderMode: VideoRenderMode.auto,

                      activeVideoTrack!,

                    )

                  : NoVideoWidget(name: widget.participant.name),

            ),

I am not sure what the issue may be. Have you looked at this yet?

Which code example are you referring to?

sorta the whole thing from their livekit flutter sdk github with connecting to rooms and widget to show video tracks.

to make this work i also need to import flutter webrtc package to get ahold of that class? I mean, why do i have this issue when i only used the code example from the sdk?

Do you mean this example?

If so, are you modifying the example in any way?

It should just work with:

  1. flutter pub get
  2. flutter pub run
  3. Generate room token for each user lk token create -r test-room

no i use “client-sdk-flutter/example at main · livekit/client-sdk-flutter · GitHub” this where i’ve copied and used this widget " client-sdk-flutter/example/lib/widgets/participant.dart at main · livekit/client-sdk-flutter · GitHub " I didnt know that livekit had its own repo with custom widgets other that the once found in the cliend sdk example… Which one are we suppose to use?!

I see that in the end the, the difference between the repo and video widget is a ValueKey

The example you are using is more foundational, to show use of the Flutter SDK itself. The components demo I shared is a bit richer and makes use of our Flutter components library which builds on top of the SDK.

If you are building a live streaming app, I would probably start with the components example. If you were building a front-end for an AI agent, I would suggest starting with GitHub - livekit-examples/agent-starter-flutter: AI voice assistant starter app for Flutter built with LiveKit · GitHub.

For your specific issue, running against client-sdk-flutter/example at main · livekit/client-sdk-flutter · GitHub , I don’t see this issue if I do the following:

  • clone repo
  • flutter pub get
  • generate two tokens using lk token create -r test-room
  • flutter run (I chose Chrome)
  • Open two windows
  • Provide wss URL for my LiveKit cloud project and the tokens
  • Enable webcam

This was just testing on my own, but I see two webcams in each Chrome tab.

We are just using livekit for video calls, nothing fancy, the first version we added was livekit_client: ^1.3.0 so we have been using it for a long time and also been apart of a lot of problems and issues (which all have been solved <3). We are doing a big migration work which also means that we are using the latest version of everything possible. I am just curious if other people are seeing the same issues as we are, because if they dont, it means that we might have other problems than the SDK itselves?

to me, it feels like a race-condition where we try to show the video track before its ready