Add the CometChat Dependency
Step 1: Add Hosted Source
Add the CometChat Cloudsmith hosted source to yourpubspec.yaml file:
Step 2: Install Dependencies
Run the following command to install the package:Add Permissions
Android
Add the required permissions to yourandroid/app/src/main/AndroidManifest.xml:
For Android 6.0 (API level 23) and above, you must request camera and microphone permissions at runtime before starting a call.
iOS
Add the following usage descriptions to yourios/Runner/Info.plist:
iOS requires usage description strings for camera and microphone access. Without these entries, the app will crash when attempting to access the camera or microphone.
Initialize CometChat Calls
Theinit() method initializes the SDK with your app credentials. Call this method once when your application starts, typically in your main() function or root widget’s initState().
CallAppSettingBuilder
TheCallAppSettingBuilder class configures the SDK initialization:
| Parameter | Type | Required | Description |
|---|---|---|---|
appId | String | Yes | Your CometChat App ID |
region | String | Yes | Your app region (us or eu) |
| Parameter | Description |
|---|---|
callAppSettings | Configuration object with App ID and Region |
onSuccess | Callback invoked when initialization succeeds |
onError | Callback invoked when initialization fails |
Check Initialization Status
You can verify if the SDK has been initialized using theisInitialized getter: