Flutter SDK

Build cross-platform video apps for iOS, Android, and Web with Flutter

Installation

Add BaxCloud SDK to your Flutter project

Add to pubspec.yaml

pubspec.yaml
1dependencies:
2  baxcloud_client:
3    path: ../path/to/baxcloud_client

Install dependencies

1flutter pub get
All required dependencies are bundled with the SDK

Platform Configuration

Required setup for iOS and Android

Add to ios/Runner/Info.plist

ios/Runner/Info.plist
1<key>NSCameraUsageDescription</key>
2<string>We need access to your camera for video calls</string>
3<key>NSMicrophoneUsageDescription</key>
4<string>We need access to your microphone for audio calls</string>

Quick Start

Get started with Flutter SDK

1. Initialize Client

lib/main.dart
1import 'package:baxcloud_client/baxcloud_client.dart';
2
3final client = BaxCloudClient(
4  projectId: 'your-project-id',
5  apiKey: 'your-api-key',
6);

2. Connect to a Room

1final room = await client.connect(
2  BaxcloudRoomOptions(
3    roomName: 'my-room',
4    participant: BaxcloudUser(
5      userId: 'user-123',
6      name: 'John Doe',
7      isHost: true,
8    ),
9    liveType: BaxcloudLiveType.videoCall,
10  ),
11);
12
13print('Connected to room: ${room.name}');

3. Render Video

1import 'package:baxcloud_client/baxcloud_client.dart';
2import 'package:flutter/material.dart';
3
4class VideoGrid extends StatelessWidget {
5  final controller = BaxCloudRoomController.instance;
6  const VideoGrid({super.key});
7  
8  
9  Widget build(BuildContext context) {
10    final participants = controller.getParticipants();
11    
12    return GridView.builder(
13      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
14        crossAxisCount: 2,
15        childAspectRatio: 3 / 4,
16      ),
17      itemCount: participants.length,
18      itemBuilder: (context, index) {
19        final participant = participants[index];
20        
21        return Stack(
22          children: [
23            // Video renderer
24            if (participant.isCameraEnabled)
25              BaxCloudVideoRenderer(
26                userId: participant.user.userId,
27                mirror: participant.isLocal,
28                fit: BoxFit.cover,
29              )
30            else
31              Container(
32                color: Colors.grey[800],
33                child: Center(
34                  child: Icon(Icons.person, size: 48, color: Colors.white54),
35                ),
36              ),
37            
38            // Participant name overlay
39            Positioned(
40              left: 8,
41              bottom: 8,
42              child: Container(
43                padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
44                decoration: BoxDecoration(
45                  color: Colors.black54,
46                  borderRadius: BorderRadius.circular(4),
47                ),
48                child: Row(
49                  mainAxisSize: MainAxisSize.min,
50                  children: [
51                    if (!participant.isMicrophoneEnabled)
52                      Padding(
53                        padding: EdgeInsets.only(right: 4),
54                        child: Icon(
55                          Icons.mic_off,
56                          size: 14,
57                          color: Colors.red,
58                        ),
59                      ),
60                    Text(
61                      '${participant.user.name ?? participant.user.userId}${participant.isLocal ? " (You)" : ""}',
62                      style: TextStyle(
63                        color: Colors.white,
64                        fontSize: 12,
65                        fontWeight: FontWeight.w500,
66                      ),
67                    ),
68                  ],
69                ),
70              ),
71            ),
72          ],
73        );
74      },
75    );
76  }
77}

4. Disconnect

1await client.disconnect();

Usage Examples

Common implementation patterns

1class VideoCallScreen extends StatefulWidget {
2  
3  _VideoCallScreenState createState() => _VideoCallScreenState();
4}
5
6class _VideoCallScreenState extends State<VideoCallScreen> {
7  late BaxCloudClient client;
8  Room? room;
9  BaxCloudConnectionState connectionState = 
10    BaxCloudConnectionState.disconnected;
11
12  
13  void initState() {
14    super.initState();
15    client = BaxCloudClient(
16      projectId: 'your-project-id',
17      apiKey: 'your-api-key',
18    );
19    _connect();
20  }
21
22  Future<void> _connect() async {
23    try {
24      setState(() {
25        connectionState = BaxCloudConnectionState.connecting;
26      });
27
28      room = await client.connect(
29        BaxcloudRoomOptions(
30          roomName: 'video-call-123',
31          participant: BaxcloudUser(
32            userId: 'user-1',
33            name: 'Alice',
34            isHost: true,
35          ),
36          liveType: BaxcloudLiveType.videoCall,
37        ),
38      );
39
40      setState(() {
41        connectionState = BaxCloudConnectionState.connected;
42      });
43    } catch (e) {
44      setState(() {
45        connectionState = BaxCloudConnectionState.failed;
46      });
47    }
48  }
49
50  
51  void dispose() {
52    client.disconnect();
53    super.dispose();
54  }
55
56  
57  Widget build(BuildContext context) {
58    return Scaffold(
59      body: Center(
60        child: Text('Connection: $connectionState'),
61      ),
62    );
63  }
64}

API Reference

Core classes and methods

BaxCloudClient

The main client class for interacting with the BaxCloud API.

1// Initialize
2final client = BaxCloudClient(
3  projectId: 'your-project-id',
4  apiKey: 'your-api-key',
5);
6
7// Connect to room
8await client.connect(options);
9
10// Enable camera/microphone
11await client.enableCamera();
12await client.enableMicrophone();
13
14// Disconnect
15await client.disconnect();

BaxCloudRoomController

Singleton controller for centralized room management.

1final controller = BaxCloudRoomController.instance;
2controller.initialize(client);
3
4// Host controls
5await controller.muteAll();
6await controller.kickParticipant(userId);
7
8// Chat
9await controller.sendChatMessage('Hello!');
10
11// Polls
12final pollId = await controller.createPoll(
13  'What is your favorite color?',
14  ['Red', 'Blue', 'Green'],
15);

Recording

1// Start recording
2final recording = await client.startRecording(
3  BaxcloudStartRecordingOptions(
4    roomName: 'my-room',
5    fileType: 'MP4',
6  ),
7);
8
9// Stop recording
10await client.stopRecording(recording.egressId);
11
12// List recordings
13final recordings = await client.listRecordings(
14  BaxcloudListRecordingsOptions(
15    status: 'COMPLETED',
16    page: 1,
17    limit: 10,
18  ),
19);

Best Practices

Recommendations for Flutter development

Use Streams for Real-time Updates

Leverage Flutter's StreamBuilder for connection state changes

Clean Up Resources

Always disconnect in dispose() method

Handle Permissions

Request camera/microphone permissions before connecting