Stringee Flutter
A Flutter plugin for Android and iOS that provides access to Stringee API services. It can be integrated into Flutter applications that need Stringee communication features.
Features
- Voice call
- Video call
- Chat 1-1, chat group
- Video conference
Getting Started
Check out our comprehensive Example provided with this plugin.
To use this package, add the dependency to your pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
stringee_plugin: ^1.3.4
See the available versions and release notes in the Changelog.
Android requirements
- Android
minSdk21 or later - Android SDK Platform 36 installed
The plugin is compiled with Android API 36. If your application declares its own compileSdk, set
it to 36 or later:
android {
compileSdk = 36
}
Required Android R8 rules are included; the app does not need package-wide Stringee or WebRTC keep rules.
iOS requirements
- iOS 15.0 or later
- Stringee iOS SDK
2.2.0, which is not published to the CocoaPods trunk. Add it toios/Podfilebeforeflutter_install_all_ios_pods:
platform :ios, '15.0'
target 'Runner' do
use_frameworks!
pod 'Stringee', :podspec => 'https://raw.githubusercontent.com/stringeecom/Stringee-iOS-SDK/2.2.0/Stringee.podspec'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Then run pod install (or pod update Stringee when upgrading from an older plugin version). The
Stringee pod brings its own WebRTC build; do not add another WebRTC pod to the app.
Basic usage
Create one StringeeClient, subscribe to its event stream, and connect it with an access token
generated by your server:
final client = StringeeClient();
final clientSubscription = client.eventStreamController.stream.listen((event) {
switch (event['eventType']) {
case StringeeClientEvents.didConnect:
print('Connected as ${client.userId}');
break;
case StringeeClientEvents.requestAccessToken:
// Fetch a new token from your server, then call client.connect(newToken).
break;
case StringeeClientEvents.incomingCall:
final call = event['body'] as StringeeCall;
// Present incoming-call UI and call call.initAnswer().
break;
case StringeeClientEvents.incomingCall2:
final call = event['body'] as StringeeCall2;
// Present incoming-call UI and call call.initAnswer().
break;
}
});
await client.connect(accessToken);
Access token renewal
About 60 seconds before the access token expires the client emits
StringeeClientEvents.tokenWillExpire. Fetch a new token for the same user from your server and
renew it on the open connection:
case StringeeClientEvents.tokenWillExpire:
final body = event['body'] as Map;
print('Token expires in ${body['expireInSeconds']}s (exp: ${body['exp']})');
final newToken = await fetchTokenFromYourServer();
final result = await client.updateToken(newToken);
if (result['status'] != true) {
print('updateToken failed: ${result['code']} ${result['message']}');
}
break;
updateToken returns {status, code, message}. The codes are the same on Android and iOS:
| Code | Meaning |
|---|---|
0 |
Success |
> 0 |
Server error: 6 expired token, 10 invalid signature, 17 user or project mismatch |
-1 |
Not connected |
-2 |
Empty token |
-4 |
No server reply within 10 seconds |
-5 |
The server has not requested renewal on this connection (call it only after tokenWillExpire) |
If the token is not renewed, the server closes the connection when it expires and the client emits
requestAccessToken (on Android it is preceded by didFailWithError with code 6); the SDK does
not reconnect by itself. Call client.connect(newToken) on the same client to resume the session.
Create and observe an outgoing call:
final call = StringeeCall(client);
final callSubscription = call.eventStreamController.stream.listen((event) {
if (event['eventType'] == StringeeCallEvents.didChangeSignalingState) {
final state = event['body'] as StringeeSignalingState;
print('Signaling state: $state');
}
});
final result = await call.makeCallFromParams(
MakeCallParams(
fromUserId,
toUserId,
isVideoCall: true,
videoQuality: VideoQuality.hd,
),
);
Video rendering
Use StringeeVideoView for Call or Call2 video. The first argument is the call ID; set isLocal
to true for the local camera and false for the remote stream:
Stack(
children: [
StringeeVideoView(
call.id!,
false,
scalingType: ScalingType.fill,
),
Positioned(
right: 16,
top: 16,
width: 120,
height: 160,
child: StringeeVideoView(
call.id!,
true,
isMirror: true,
scalingType: ScalingType.fit,
),
),
],
)
On Android, the widget may be created before the native local or remote renderer is ready. The plugin keeps the requested mirror and scaling options, then attaches the renderer when the stream becomes available. A native renderer can belong to only one Android view, so rebuilding it at a new location moves it from the previous container. Removing the Flutter widget clears its pending attachment safely.
For video conference tracks, use track.attach(...), which returns a StringeeVideoView bound to
that track:
final remoteView = track.attach(
scalingType: ScalingType.fit,
isMirror: false,
);
Release object-level subscriptions when they are no longer needed:
await callSubscription.cancel();
call.destroy();
await clientSubscription.cancel();
await client.disconnect();
StringeeCall2, StringeeChat, and StringeeVideoRoom expose their own event streams. Call their
destroy() method after use so the plugin can close the corresponding stream subscription.
API documentation
Public Flutter APIs include DartDoc for classes, constructors, fields, event values, and methods. Generate browsable API documentation locally with:
dart doc --validate-links
The generated site is written to doc/api/index.html. Android bridge classes and methods include
JavaDoc that is available in IDE source documentation.
Check out our getting-started guides:
- Getting started with Stringee Call API using Flutter Plugin
- Getting started with Stringee Call2 API using Flutter Plugin
- Getting started with Stringee Chat API using Flutter Plugin
- Getting started with Stringee Video Conference API using Flutter Plugin
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Libraries
- stringee_plugin
- Flutter bindings for Stringee voice, video, chat, and conferencing APIs.