rqmeet_flutter_sdk 1.0.2
rqmeet_flutter_sdk: ^1.0.2 copied to clipboard
A high-level Flutter SDK for integrating RQMeet video meetings. Includes ready-to-use UI components (PreJoin, MeetingRoom) and a powerful real-time client.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:rqmeet_flutter_sdk/rqmeet_flutter_sdk.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RQMeet SDK Example',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final _apiKeyController = TextEditingController(text: 'your_api_key');
final _meetingIdController = TextEditingController();
final _nameController = TextEditingController(text: 'Flutter User');
bool _isLoading = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('RQMeet SDK Example'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: _apiKeyController,
decoration: const InputDecoration(labelText: 'API Key'),
),
TextField(
controller: _meetingIdController,
decoration: const InputDecoration(labelText: 'Meeting ID'),
),
TextField(
controller: _nameController,
decoration: const InputDecoration(labelText: 'Your Name'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _isLoading ? null : _joinMeeting,
child: _isLoading
? const CircularProgressIndicator()
: const Text('Join Meeting'),
),
],
),
),
);
}
Future<void> _joinMeeting() async {
final apiKey = _apiKeyController.text.trim();
final meetingId = _meetingIdController.text.trim();
final name = _nameController.text.trim();
if (apiKey.isEmpty || meetingId.isEmpty || name.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Please fill all fields')),
);
return;
}
setState(() => _isLoading = true);
try {
final client = RQMeetClient(apiKey: apiKey);
// Get join token
final response = await client.getJoinToken(
meetingId: meetingId,
identity: 'user_${DateTime.now().millisecondsSinceEpoch}',
name: name,
);
if (!mounted) return;
// Navigate to meeting room
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
body: MeetingRoom(
meetingId: meetingId,
client: client,
token: response.token,
serverUrl: response.serverUrl,
identity: response.identity,
role: response.role,
permissions: response.permissions,
initialAudioEnabled: true,
initialVideoEnabled: true,
onLeave: () => Navigator.pop(context),
),
),
),
);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Error: $e')),
);
} finally {
setState(() => _isLoading = false);
}
}
}