I found the answer if someone is interested.
So first import the library:
import 'package:agora_rtc_engine/rtc_engine.dart';
And then declare this variable:
late RtcEngine _engine;
Then add this function and add your own code:
Future <void> setHandler() async {
_engine = await RtcEngine.createWithConfig(RtcEngineConfig("$REMOTE_VIDEO_UID"));
await _engine.enableVideo();
_engine.setEventHandler(
RtcEngineEventHandler(
joinChannelSuccess: (String channel, int uid, int elapsed) {
print("Local user has joined the call!");
// Your code goes here
},
userJoined: (int uid, int elapsed) {
print("Local user has joined the call!");
// Your code goes here
},
userOffline: (int uid, UserOfflineReason reason) {
print("remote user has left the call!");
// Your code goes here
},
),
);
}
And finally call the handler like this within your preferred state:
setState(
() {
setHandler();
},
);
Thanks to this guy for his tutorial.