socrits 0.1.2
socrits: ^0.1.2 copied to clipboard
Socrits SDK for Flutter - video & voice calls, call invitations (ring/accept), and in-app chat. Drop-in prebuilt UI kit plus a low-level core client.
socrits #
The Socrits Flutter SDK — real-time audio & video calls, call invitations (ring / accept / reject), in-app chat, plus a prebuilt call UI and a low-level core client. Media runs on LiveKit.
Install #
flutter pub add socrits
Quick start #
import 'package:socrits/socrits.dart';
final sc = Socrits(baseUrl: 'https://api.socrits.example');
// Your backend mints the user token via POST /v1/session (API key stays server-side).
await sc.connect(sessionEndpoint: 'https://your-backend/sc-session', userId: 'alice');
// A ring arrives → show your incoming-call UI.
sc.onIncomingCall = (call) {
// call.fromUserName, call.mode …
// sc.accept(call); or sc.reject(call);
};
// Call connected → render the media room with the prebuilt call UI.
sc.onCallConnected = (room, mode) {
Navigator.push(context, MaterialPageRoute(builder: (_) => Scaffold(
body: SocritsCallView(room: room, onHangUp: () => Navigator.pop(context)),
)));
};
sc.onCallRejected = (callId) {}; // callee declined
sc.onCallEnded = (reason) {}; // 'timeout' (no answer) | 'cancelled'
// Place a call.
final callId = await sc.invite(toUserId: 'bob', mode: CallMode.video);
// Send custom in-call data over the room's data channel.
sc.sendData('bob', callId, {'coin_balance': 120});
sc.onData = (from, data) { /* … */ };
Two ways to build the call screen #
UI Kit — SocritsCallView. A drop-in call screen: video grid with mic,
camera and hang-up controls. Pass the connected room and you're done.
SocritsCallView(room: room, title: 'Bob', onHangUp: () => Navigator.pop(context));
Core — build your own. Render the LiveKit room yourself with your own
layout, controls and effects for full design control.
Native ringing (offline / CallKit) #
So a call rings on a locked phone with the app closed:
- Register the device after connecting:
final fcmToken = await FirebaseMessaging.instance.getToken(); sc.registerDevice(fcmToken!); // stored server-side per user - Socrits pushes an
incoming_callFCM data message when the callee is offline (setFCM_SERVICE_ACCOUNTon the server to enable real sends). - In your FCM background handler, show native UI with
flutter_callkit_incoming; on accept,connect()andaccept(call)to join.
The push payload carries callId, room, mode, fromUserId, fromUserName.
Documentation #
Full guides at socrits.com/docs/flutter.
Maintainer #
Built and maintained by SuryaPrakash Malgo · socrits.com