class VideoCallWidget extends StatefulWidget {
const VideoCallWidget({
super.key,
this.width,
this.height,
});
final double? width;
final double? height;
@override
State<VideoCallWidget> createState() => _VideoCallWidgetState();
}
class _VideoCallWidgetState extends State<VideoCallWidget> {
late RtcEngine _engine;
bool _isJoined = false;
@override
void initState() {
super.initState();
_initializeAgora();
}
Future<void> _initializeAgora() async {
try {
_engine = createAgoraRtcEngine();
await _engine.initialize(
RtcEngineContext(
appId: appId,
),
);
_engine.registerEventHandler(
RtcEngineEventHandler(
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
setState(() {
_isJoined = true;
});
},
onLeaveChannel: (RtcConnection connection, RtcStats stats) {
setState(() {
_isJoined = false;
});
},
),
);
await _engine.joinChannel(
token: token,
channelId: channel,
uid: 0,
options: ChannelMediaOptions(),
);
} catch (e) {
_printError(e.toString());
}
}
void _printError(String message) {
print("Error: $message");
}
@override
void dispose() {
_engine.leaveChannel();
_engine.release();
super.dispose();
}
@override
Widget build(BuildContext context) {
return _isJoined
? AgoraVideoView(
controller: VideoViewController(
rtcEngine: _engine,
canvas: const VideoCanvas(uid: 0),
),
)
: Center(child: CircularProgressIndicator());
}
}
Error: TypeError: Cannot read properties of undefined (reading 'createIrisApiEngine')
Custom Code
i want to build videochat app in agora. i write the this for testing but here the agora channel did not create that is why i can not proceed further ahead.
No
1 reply