Initializing and using the SDK
Getting token
After completing the installation phase, you must initialize the SDK with a profile token from the server and other necessary information.
In Flutter, you will pass this token to the native SDKs via the startVideo(...) call (over MethodChannel).
Overview (Flutter)
The Flutter Video SDK is a thin bridge around the native iOS and Android SDKs.
- Flutter uses a MethodChannel to send commands to native (
startVideo,switchCamera,toggleTorch,closeSDK, etc.). - Flutter uses an EventChannel to receive native UI/remote events (agent requests) as a Stream.
Note: Native SDKs have their own initialization patterns (iOS uses
AmaniVideoBuilder, Android usesVideoSDK.Builder).
In Flutter, you do not create those builders directly; instead, you provide the required values tostartVideo(...)and native side builds internally.
Channel names
- MethodChannel:
amanivideosdk_method_channel - EventChannel (delegate/events):
amanivideosdk_delegate_channel
Initializing (Flutter)
Create a VideoSDK instance and call startVideo(...).
On iOS, you should also call setAmaniVideoDelegate() after starting, because iOS native side requires a delegate to forward UI/remote events.
The native iOS SDK uses
AmaniVideoBuilder(as shown in the native iOS documentation), and the Flutter plugin internally builds it using the values you pass from Dart.
Flutter Wrapper Example - Dart
class AmaniVideoSDKScreen extends StatefulWidget {
const AmaniVideoSDKScreen({Key? key}) : super(key: key);
State<AmaniVideoSDKScreen> createState() => _AmaniVideoSDKScreenState();
}
class _AmaniVideoSDKScreenState extends State<AmaniVideoSDKScreen> {
final VideoSDK _videoSDKModule = FlutterVideosdkamani().getAmaniVideo();
static const EventChannel _videoEventChannel =
EventChannel('amanivideosdk_delegate_channel');
StreamSubscription? _videoStreamSubscription;
void initState() {
super.initState();
_videoStreamSubscription =
_videoEventChannel.receiveBroadcastStream().listen(_handleNativeEvent);
}
void _handleNativeEvent(dynamic event) {
debugPrint("Native Event: $event");
if (event == "camera_switch_requested") {
_videoSDKModule.switchCamera();
} else if (event == "torch_toggle_requested") {
_videoSDKModule.toggleTorch();
} else if (event == "on_ui_call_end") {
_videoSDKModule.closeSDK();
} else if (event == "call_end") {
_videoSDKModule.closeSDK().then((_) {
debugPrint("navigate did pop");
});
}
}
void dispose() {
_videoStreamSubscription?.cancel();
super.dispose();
}
Future<void> setupVideoBuilder() async {
_videoSDKModule.startVideo(
"server_url",
"token",
"name",
"surname",
"stun_server",
"turn_server",
"st_user",
"pass",
);
/// iOS-only: required to receive events from native delegate
_videoSDKModule.setAmaniVideoDelegate();
}
Future<bool> onWillPop() async {
return true;
}
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: onWillPop,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.purple,
title: const Text('Amani Video Screen'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: () {
setupVideoBuilder();
},
child: const Text("Start"),
),
],
),
),
),
);
}
}
Event Names
- camera_switch_requested
- torch_toggle_requested
- on_ui_call_end
- call_end
These event names are emitted by your native EventChannel handlers. The event meaning is common across platforms (camera/torch/call end), but the native implementation differs: iOS emits delegate events based on AmaniVideoDelegate Android emits observer events based on AmaniVideoCallObserver / internal plugin event handler.
Setting up the event listeners
-
Android delivers events using the same EventChannel (amanivideosdk_delegate_channel), so you can reuse the same listener implementation from the iOS section.
-
Common behavior across platforms: EventChannel stream + shared event meanings (camera/torch/call end) Different native sources: Android derives these events from observer/callback flow.