agora_rtc_wrapper 0.0.11 agora_rtc_wrapper: ^0.0.11 copied to clipboard
Simple wrapper utils for agora rtc implementation in flutter
import 'package:agora_rtc_wrapper/agora_rtc_wrapper.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: VideoCallScreen(
channelId: 'test',
),
);
}
}
class VideoCallScreen extends StatefulWidget {
final String channelId;
VideoCallScreen({@required this.channelId});
@override
_VideoCallScreenState createState() => _VideoCallScreenState();
}
class _VideoCallScreenState extends State<VideoCallScreen> {
int joinedUId = -1;
@override
void initState() {
super.initState();
AgoraRtcWrapper.instance.init('Your Agora App Id');
AgoraRtcWrapper.instance.listen(onUserJoined: _onUserJoined);
if (widget.channelId != null && widget.channelId.isNotEmpty) {
AgoraRtcWrapper.instance.joinChannel(widget.channelId);
}
}
void _onUserJoined(int uid, int elapsed) {
setState(() {
joinedUId = uid;
});
}
@override
void dispose() {
AgoraRtcWrapper.instance.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: Text('Video Call Test'),
),
body: Stack(
children: <Widget>[
joinedUId != -1
? AgoraRtcWrapper.instance.getVideoView(joinedUId)
: Container(),
Positioned(
right: 0,
child: SizedBox(
height: 180,
width: 150,
child: AgoraRtcWrapper.instance.getSelfVideoView,
),
),
AgoraRtcWrapper.instance.getDefaultController(
onCallEnd: () {
Navigator.pop(context);
},
onMute: (isMute) {
setState(() {
AgoraRtcWrapper.instance.muteAudio(!isMute);
});
},
)
],
),
);
}
}