vact_sdk 2.2.2
vact_sdk: ^2.2.2 copied to clipboard
Dependency-free one-to-one voice and video calling for VACT. Plain HTTPS plus WebRTC.
example/README.md
vact_sdk example #
Full runnable apps (with Node and Firebase backends) live at https://github.com/danishktabbas/vact-example. Sign up free at https://vact.online for an App ID and ₹100 of credit.
The whole client flow is: connect → call / accept → render → end.
import 'package:vact_sdk/vact_sdk.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
final vact = Vact(appId: 'vact_app_your_public_app_id');
// 1. Connect with a one-time token minted by YOUR backend.
await vact.connect(accessToken: accessTokenFromYourBackend);
// 2. Receive calls (handle one at a time; de-dupe by id).
String? prompting;
vact.incomingCalls().listen((calls) async {
if (prompting != null || calls.isEmpty) return;
final incoming = calls.first;
prompting = incoming.id;
final call = await vact.accept(incoming); // or vact.decline(incoming)
prompting = null;
_render(call);
});
// 3. Or place a call.
final call = await vact.call('user_42', video: true);
_render(call);
// 4. Show the video — re-attach the remote renderer when the track arrives.
void _render(VactCall call) async {
final remote = RTCVideoRenderer();
await remote.initialize();
remote.srcObject = call.remoteStream;
call.onRemoteTrack = () => remote.srcObject = call.remoteStream; // key line
// RTCVideoView(remote) and RTCVideoView(localRenderer, mirror: true)
call.states.listen((s) {
if (s == VactCallState.ended || s == VactCallState.failed) {/* pop screen */}
});
}
// 5. End.
await call.end();
Android needs minSdkVersion 23 and camera/mic permissions; iOS needs the
Info.plist usage strings and deployment target 13. See the package README and
https://vact.online/docs.html for the exact per-platform setup.