-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Description
Describe the bug
I am trying to use livekit_client in a new Flutter project, but I am getting "Undefined method 'AccessToken'" and "Undefined method 'VideoGrant'" errors. I have followed all the setup steps.
To Reproduce
- Create a new Flutter project.
- Add
livekit_client: anytopubspec.yaml. - Run
flutter pub get. - Use the following code in
main.dart.
Code sample
import 'package:flutter/material.dart';
import 'package:livekit_client/livekit_client.dart';
// My Keys
const String LIVEKIT_URL = 'wss://...'; // Replaced with my actual URL
const String LIVEKIT_API_KEY = 'API...'; // Replaced with my actual Key
const String LIVEKIT_API_SECRET = '...'; // Replaced with my actual Secret
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) => const MaterialApp(home: HomePage());
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
String createAccessToken() {
final token = AccessToken(
LIVEKIT_API_KEY,
LIVEKIT_API_SECRET,
identity: 'test-user',
name: 'Test User',
);
token.setGrant(VideoGrant(
room: 'test-room',
roomJoin: true,
));
return token.toJwt();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
try {
createAccessToken();
print('Success!');
} catch (e) {
print('Error: $e');
}
},
child: const Text('Test Token'),
),
),
);
}
}
Expected behavior
The code should compile without errors, and AccessToken and VideoGrant should be recognized.
Platform information
OS: Windows
Flutter version:
[ Flutter 3.35.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision adc9010625 (7 days ago) • 2025-10-21 14:16:03 -0400
Engine • hash 6b24e1b529bc46df7ff397667502719a2a8b6b72 (revision 035316565a) (7 days ago) • 2025-10-2114:28:01.000Z ]
Tools • Dart 3.9.2 • DevTools 2.48.0
livekit_client version: 2.5.3
Additional context
I have already tried flutter clean, flutter pub cache repair, and restarting the IDE. The errors persist. It seems like the necessary classes are not being exported correctly from the library. Am I missing a specific import?Metadata
Metadata
Assignees
Labels
No labels