πŸš€ Flutter WebRTC Fixed v0.12.0

pub package GitHub stars License Flutter WebRTC

🎯 Production-Ready WebRTC Plugin for Flutter

Cross-platform real-time communication with enhanced stability and performance


✨ What's New

πŸŽ‰ This is a fixed and improved version of the original flutter_webrtc package with:

  • πŸ”§ Enhanced Stability - Additional bug fixes and optimizations
  • πŸš€ Production Ready - Tested and optimized for production use
  • πŸ“± Cross-Platform - iOS, Android, Web, macOS, Windows, Linux support
  • πŸ› οΈ Easy Integration - Simple API with comprehensive documentation

Sponsored with πŸ’–   by
Stream Chat
Enterprise Grade APIs for Feeds, Chat, & Video. Try the Flutter Video tutorial πŸ’¬


LiveKit
LiveKit - Open source WebRTC infrastructure

πŸ“¦ Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_webrtc_fixed_v0_12_0: ^0.12.0

Then run:

flutter pub get

πŸ”— Alternative Installation Methods

πŸ“₯ From GitHub Repository
dependencies:
  flutter_webrtc_fixed_v0_12_0:
    git:
      url: https://github.com/boughdiri-dorsaf/flutter_webrtc_fixed_v0.12.0.git
      ref: main
πŸ“ From Local Path
dependencies:
  flutter_webrtc_fixed_v0_12_0:
    path: ./flutter_webrtc_fixed_v0_12_0

πŸš€ Features

🌟 Core Capabilities

🎯 Feature πŸ€– Android 🍎 iOS 🌐 Web πŸ’» macOS πŸͺŸ Windows 🐧 Linux πŸ“± Embedded
πŸŽ₯ Audio/Video βœ… βœ… βœ… βœ… βœ… βœ… βœ…
πŸ“‘ Data Channel βœ… βœ… βœ… βœ… βœ… βœ… βœ…
πŸ“Ί Screen Capture βœ… βœ…* βœ… βœ… βœ… βœ… βœ…
πŸ”„ Unified-Plan βœ… βœ… βœ… βœ… βœ… βœ… βœ…
πŸ“Š Simulcast βœ… βœ… βœ… βœ… βœ… βœ… βœ…
🎬 MediaRecorder ⚠️ ⚠️ βœ… ❌ ❌ ❌ ❌
πŸ” End-to-End Encryption βœ… βœ… βœ… βœ… βœ… βœ… βœ…
πŸ”Œ Insertable Streams ❌ ❌ ❌ ❌ ❌ ❌ ❌

iOS Screen Sharing requires additional setup - See Guide

🎨 Key Highlights

  • 🎯 Cross-Platform Support - Works seamlessly across all major platforms
  • πŸ”§ Production Ready - Battle-tested in real-world applications
  • πŸš€ High Performance - Optimized for low latency and high quality
  • πŸ›‘οΈ Secure - Built-in encryption and security features
  • πŸ“± Mobile First - Designed with mobile devices in mind
  • 🌐 Web Compatible - Full support for Flutter Web with WASM compatibility
  • πŸ“¦ Swift Package Manager - Native iOS/macOS support via SPM
  • ⚑ Modern Web - WASM-compatible for better performance

Additional platform/OS support from the other community

πŸ› οΈ Setup

πŸ“± iOS Setup

πŸ”§ Required Permissions

Add the following entries to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) Camera Usage!</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) Microphone Usage!</string>

This allows your app to access camera and microphone.

⚠️ Important iOS Configuration

The WebRTC.xframework compiled after the m104 release no longer supports iOS arm devices. Add this to your ios/Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      # Workaround for https://github.com/flutter/flutter/issues/64502
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' # <= this line
    end
  end
end

πŸ€– Android Setup

πŸ”§ Required Permissions

Add these permissions to your AndroidManifest.xml file:

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
🎧 Bluetooth Support (Optional)

For Bluetooth device support, add these permissions:

<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
βš™οΈ Java 8 Configuration

Add this to your app-level build.gradle:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

πŸ”§ Usage

πŸš€ Quick Start

πŸ“‘ Basic WebRTC Setup
import 'package:flutter_webrtc_fixed_v0_12_0/flutter_webrtc_fixed_v0_12_0.dart';

// Create RTCPeerConnection
final configuration = {
  'iceServers': [
    {'urls': 'stun:stun.l.google.com:19302'},
  ]
};

RTCPeerConnection pc = await createPeerConnection(configuration);

// Add local stream
MediaStream localStream = await navigator.mediaDevices.getUserMedia({
  'audio': true,
  'video': true
});

localStream.getTracks().forEach((track) {
  pc.addTrack(track, localStream);
});
πŸ“± Complete Example App

Check out the complete example app that demonstrates:

  • Video capture and rendering
  • Peer connection management
  • Audio/video controls
  • Cross-platform compatibility

To run the example:

cd example
flutter pub get
flutter run
πŸŽ₯ Video Rendering
RTCVideoRenderer localRenderer = RTCVideoRenderer();
RTCVideoRenderer remoteRenderer = RTCVideoRenderer();

@override
void initState() {
  super.initState();
  localRenderer.initialize();
  remoteRenderer.initialize();
}

@override
void dispose() {
  localRenderer.dispose();
  remoteRenderer.dispose();
  super.dispose();
}

// Set video stream
localRenderer.srcObject = localStream;
remoteRenderer.srcObject = remoteStream;

🌐 Web & WASM Support

⚑ WASM Compatibility

This package includes WASM-compatible implementations for better web performance:

  • Modern Web Standards: Uses latest web APIs
  • Better Performance: WASM provides faster execution
  • Future-Proof: Ready for upcoming web technologies
  • Automatic Fallback: Gracefully falls back to standard web implementation
πŸ“¦ Swift Package Manager Support

Native iOS/macOS support via Swift Package Manager:

// Add to your Package.swift
dependencies: [
    .package(url: "https://github.com/boughdiri-dorsaf/flutter_webrtc_fixed_v0.12.0.git", from: "0.12.0")
]

Benefits:

  • Native Integration: Direct Swift/Objective-C integration
  • Better Performance: Optimized for iOS/macOS
  • Modern Tooling: Works with Xcode's modern build system
  • Dependency Management: Clean dependency resolution

πŸ“‹ API Reference

πŸ—οΈ Core Classes

Class Description
RTCPeerConnection WebRTC peer connection management
MediaStream Audio/video stream handling
RTCVideoRenderer Video rendering widget
RTCDataChannel Data channel for messaging

πŸ”§ Key Methods

Method Description
createPeerConnection(configuration) Create peer connection
getUserMedia(constraints) Get media stream
addTrack(track, stream) Add media track
createOffer() / createAnswer() Create SDP offer/answer
setLocalDescription(description) Set local SDP
setRemoteDescription(description) Set remote SDP

🚨 Troubleshooting

πŸ” Common Issues

πŸ“· Camera Permission Issues
  • Ensure camera permissions are properly set in platform-specific files
  • Check Info.plist (iOS) and AndroidManifest.xml (Android)
  • Verify runtime permission requests
🎀 Audio Issues
  • Check microphone permissions and audio settings
  • Verify audio device selection
  • Test with different audio configurations
🌐 Network Issues
  • Verify STUN/TURN server configuration
  • Check firewall and NAT settings
  • Test with different network conditions
🍎 iOS Build Issues
  • Ensure ONLY_ACTIVE_ARCH is set to 'YES' in Podfile
  • Check Xcode version compatibility
  • Verify iOS deployment target

πŸ› Debug Information

// Check peer connection state
pc.onConnectionState = (RTCPeerConnectionState state) {
  print('Connection state: $state');
};

// Check ICE connection state
pc.onIceConnectionState = (RTCIceConnectionState state) {
  print('ICE connection state: $state');
};

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/amazing-feature)
  3. ✏️ Make your changes
  4. πŸ§ͺ Test thoroughly
  5. πŸ“€ Submit a pull request

πŸ“‹ Contribution Guidelines

  • Follow the existing code style
  • Add tests for new features
  • Update documentation as needed
  • Ensure all tests pass

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

πŸ†˜ Need Help?

  • πŸ› Report Issues: GitHub Issues
  • πŸ“– Documentation: Check the troubleshooting section above
  • πŸ” API Reference: Review the comprehensive API documentation
  • πŸ’‘ This is a fixed version of the original flutter_webrtc package

🌟 Show Your Support

If this package helped you, please give it a ⭐ on GitHub!

πŸ”„ Updates

This package is maintained and updated regularly. Check the CHANGELOG.md for version history and updates.


🎯 Ready to build amazing real-time communication apps?

Get Started View on GitHub

This version is optimized for production use and includes all necessary fixes and improvements.