Video producers start live streams from their phones during events or training. Viewers join instantly on apps to watch with low delay. The Agora Flutter SDK connects everyone in a channel, handling camera feeds and audio smoothly across devices.
Prerequisites
You need Flutter set up and an Agora App ID to generate secure connections for live video. Camera permissions ensure smooth access to device hardware without interruptions during streams.
- Flutter SDK is installed on the development machine.
- Agora developer account with an App ID from the console.
- Agora RTC Engine package added to pubspec.yaml.
- Camera and microphone permissions granted in app manifests.
- A channel name chosen for the live session.
- Test devices are ready for the broadcaster and audience roles.
Setting Up the Stream
Developers initialize the Agora engine with an App ID to create a foundation for real-time video exchange. This step configures video settings so broadcasters and viewers connect reliably in live mode.
Step 1: Add the Agora RTC Engine dependency to pubspec.yaml and run flutter pub get.
Step 2: Import the package in the main Dart file.
Step 3: Create an RtcEngine instance using the App ID from the Agora console.
Step 4: Enable video in the engine settings.
Step 5: Set the channel profile to live broadcasting mode.
Starting as a Broadcaster
Broadcasters join a channel to push their camera feed live to all viewers. This role activates local preview and transmission, enabling real-time delivery without delays.
Step 1: Request camera and microphone permissions from the user.
Step 2: Join the channel with the channel name and a temporary token.
Step 3: Set the local video view to show the camera preview.
Step 4: Start the video stream, pushing feed to the channel.
Step 5: Handle events like user join or mute button presses.
Joining as an Audience
Viewers enter the same channel to receive and play the broadcaster's video stream. This setup subscribes to incoming feeds, rendering them instantly on screen for live watching.
Step 1: Enter the same channel name in the viewer app.
Step 2: Join the channel as an audience member.
Step 3: Create a remote video view widget for incoming streams.
Step 4: Subscribe to remote video tracks automatically.
Step 5: Display the broadcaster's feed once connected.
Adding Chat During Stream
Chat lets broadcasters and viewers exchange messages alongside the video feed. Real-time messaging keeps everyone engaged, syncing text updates without slowing the stream.
Step 1: Add the Agora RTM package for real-time messages.
Step 2: Create an RTM client and connect with the App ID.
Step 3: Join the channel's message channel for broadcasts.
Step 4: Send text messages to the channel from the input field.
Step 5: Listen for incoming messages and update the chat list.
Handling Stream End
Ending the stream releases resources and clears channel connections cleanly. This prevents memory leaks and prepares the app for the next session or shutdown.
Step 1: Press the leave button to exit the channel.
Step 2: Stop local video and release the RtcEngine instance.
Step 3: Dispose of the RTM client to clear connections.
Step 4: Update UI to show stream ended status.
Step 5: Save stream metadata like duration if needed."

