socrits 0.1.2 copy "socrits: ^0.1.2" to clipboard
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:

  1. Register the device after connecting:
    final fcmToken = await FirebaseMessaging.instance.getToken();
    sc.registerDevice(fcmToken!);        // stored server-side per user
    
  2. Socrits pushes an incoming_call FCM data message when the callee is offline (set FCM_SERVICE_ACCOUNT on the server to enable real sends).
  3. In your FCM background handler, show native UI with flutter_callkit_incoming; on accept, connect() and accept(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

1
likes
110
points
69
downloads

Documentation

Documentation
API reference

Publisher

verified publishersocrits.com

Weekly Downloads

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.

Homepage

Topics

#video #voip #webrtc #chat #calling

License

MIT (license)

Dependencies

flutter, http, livekit_client, socket_io_client

More

Packages that depend on socrits