โญ If you find this project helpful, please give it a star! โญ
A Flutter-based live streaming application using Agora SDK with full host control over viewers and co-hosts. Perfect for creating Instagram-style live streams where the host can invite co-hosts and control who watches.
- Features
- Demo
- Prerequisites
- Setup Instructions
- How to Use
- Project Structure
- Access Code System
- Permissions
- Troubleshooting
- Dependencies
| Feature | Description |
|---|---|
| ๐ฌ Host Live Stream | Start a live stream with your own channel name |
| ๐ฅ Co-Host Support | Invite others to broadcast alongside you (split-screen view) |
| ๐ Viewer Mode | Allow viewers to watch without broadcasting |
| ๐ Access Control | Host controls who can join via unique access codes |
| ๐ค Audio Controls | Mute/unmute microphone during stream |
| ๐น Video Controls | Turn camera on/off during stream |
| ๐ค Easy Sharing | Share access codes via any app or copy to clipboard |
| ๐ฑ Cross-Platform | Works on Android, iOS, macOS, Linux, and Windows |
The GIF above shows the complete flow:
- Host starts a stream
- Host shares viewer/co-host codes
- Viewers and co-hosts join using the codes
- Split-screen view when co-host joins
Before running this app, make sure you have:
- โ Flutter SDK (version 3.10.4 or higher)
- โ Dart SDK (comes with Flutter)
- โ Android Studio or Xcode (for mobile development)
- โ Agora Account (free tier available)
git clone <your-repo-url>
cd Agora-Live-Streaming-AppIMPORTANT: This app requires an Agora App ID to work. Without it, the live streaming will not function.
- Go to Agora Console
- Sign up for a free account (or log in)
- Click "Create a Project"
- Enter a project name (e.g., "LiveStreamApp")
- Select "APP ID" as the authentication mechanism (NOT Token)
- Click "Submit"
- Copy your App ID from the project dashboard
-
Navigate to the
frontendfolder:cd frontend -
Create or edit the
.envfile:# Create .env file if it doesn't exist touch .env -
Add your Agora App ID to the
.envfile:APP_ID=your_agora_app_id_here
Example:
APP_ID=48bd29358ed64d50a2496ca432adf444
โ ๏ธ Security Note: Never commit your actual App ID to public repositories. The.envfile should be in.gitignore.
cd frontend
flutter pub get# For Android
flutter run -d android
# For iOS
flutter run -d ios
# For macOS
flutter run -d macos
# For any available device
flutter run- Open the app
- Enter a Channel Name (e.g., "mystream", "gaming", "cooking")
- Tap "Start as Host"
- Grant camera and microphone permissions when prompted
- You're now live! ๐ด
- Tap the Share icon (top right) to get access codes
- Share the codes with your audience:
- Viewer Code โ For people who want to watch
- Co-Host Code โ For people who want to broadcast with you
- Get the Viewer Access Code from the host
- Open the app
- Paste the code in the "Access Code" field
- Tap "Join Stream"
- Enjoy watching! ๐บ
- Get the Co-Host Access Code from the host
- Open the app
- Paste the code in the "Access Code" field
- Tap "Join Stream"
- Grant camera and microphone permissions
- You're now broadcasting alongside the host! ๐ฅ
Agora-Live-Streaming-App/
โโโ README.md # This file
โโโ agora_live_streaming.gif # Demo GIF
โโโ agora_live_streaming.mp4 # Demo video
โโโ agora_live_streaming.mov # Demo video (original)
โ
โโโ frontend/ # Flutter app
โโโ .env # โ ๏ธ Contains your Agora App ID
โโโ pubspec.yaml # Dependencies
โโโ lib/
โ โโโ main.dart # Main app code
โ โโโ live_stream_screen.dart
โโโ android/ # Android-specific files
โโโ ios/ # iOS-specific files
โโโ macos/ # macOS-specific files
โโโ linux/ # Linux-specific files
โโโ test/ # Test files
The app uses a simple but effective code-based access control:
| Type | Format | Example |
|---|---|---|
| Viewer | channelName_viewer_XXXXXX |
mystream_viewer_123456 |
| Co-Host | channelName_cohost_XXXXXX |
mystream_cohost_789012 |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HOST โ
โ โ
โ 1. Creates channel "mystream" โ
โ 2. Generates unique codes: โ
โ โข Viewer Code: mystream_viewer_123456 โ
โ โข Co-Host Code: mystream_cohost_789012 โ
โ 3. Shares codes selectively โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VIEWER โ โ CO-HOST โ
โ โ โ โ
โ โข Enters viewer code โ โ โข Enters co-host code โ
โ โข Can only watch โ โ โข Can broadcast video โ
โ โข No camera/mic needed โ โ โข Appears in split view โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
- โ Simple - No complex signaling infrastructure needed
- โ Reliable - Works without additional messaging SDK
- โ Host Control - Host decides who gets which code
- โ Easy to Share - Codes can be shared via any messaging app
| Permission | Purpose |
|---|---|
INTERNET |
Network access for streaming |
CAMERA |
Video broadcasting |
RECORD_AUDIO |
Audio broadcasting |
MODIFY_AUDIO_SETTINGS |
Audio configuration |
ACCESS_NETWORK_STATE |
Network status |
BLUETOOTH |
Bluetooth audio devices |
ACCESS_WIFI_STATE |
WiFi status |
| Permission | Description in App |
|---|---|
NSCameraUsageDescription |
"This app needs camera access for live streaming" |
NSMicrophoneUsageDescription |
"This app needs microphone access for live streaming" |
The app automatically:
- Requests permissions when you try to start/join as host or co-host
- Shows a dialog if permissions are denied
- Offers to open device settings if permissions are permanently denied
| Issue | Solution |
|---|---|
| "Camera/Mic not working" | Grant permissions in device settings |
| "Cannot connect to stream" | Check your internet connection |
| "Invalid code" | Make sure you copied the entire code |
| "App crashes on start" | Verify your Agora App ID in .env file |
| "Black screen on video" | Restart the app and grant camera permission |
โ ๏ธ Note: iOS Simulator does NOT support camera or microphone hardware. Test on a real iOS device or use Android emulator/macOS for full functionality.
Android:
- Go to Settings โ Apps โ Live Stream โ Permissions
- Enable Camera and Microphone
iOS:
- Go to Settings โ Privacy โ Camera/Microphone
- Enable for Live Stream app
| Package | Version | Purpose |
|---|---|---|
agora_rtc_engine |
^6.3.0 | Agora's Flutter SDK for video streaming |
permission_handler |
^11.0.1 | Request camera/mic permissions |
share_plus |
^7.2.2 | Share access codes |
flutter_dotenv |
^5.1.0 | Load environment variables (.env file) |
cupertino_icons |
^1.0.8 | iOS-style icons |
| Button | Action |
|---|---|
| ๐ค Mic | Toggle microphone on/off |
| ๐น Camera | Toggle camera on/off |
| ๐ End | Leave the stream |
| ๐ค Share | View and share access codes |
| Button | Action |
|---|---|
| ๐ End | Leave the stream |
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
If you encounter any issues:
- Check the Troubleshooting section
- Review Agora Documentation
- Open an issue in this repository
Made with โค๏ธ using Flutter and Agora SDK
