Skip to main content

Flutter Core SDK Quickstart

This quickstart shows how to use Dyte's Flutter Core SDK to add live video and audio call to your Flutter applications.

For getting started quickly, you can use our sample code. You can clone and run a sample application from the Flutter Core SDK GitHub repository.

Objective

You'll learn how to:

  • Install the Dyte SDK
  • Initialize the SDK
  • Configure a Dyte meeting
  • Initialize the Dyte meeting
  • And go live with your Dyte meeting

Before Getting Started

  • Make sure you've read the Getting Started with Dyte topic and completed the steps in the Integrate Dyte section. You must complete the following steps:
  • Install Flutter on your system
  • (For iOS apps) Install Xcode
  • Ensure that Rosetta is installed with Xcode on Mac computers with Apple silicon.
  • Make sure your Mac computers are running macOS version 12.0 Monterey or higher.
  • (For Android apps) Install Android Studio, or install the Android SDK for Command-Line Interface (CLI) only.

Step 1: Install the SDK

  1. To install the SDK, add the Dyte Core Flutter SDK dependency into the pubspec.yaml file.

    flutter pub add dyte_core
  2. Then import the following package into your project:

    import 'package:dyte_core/dyte_core.dart';

After importing the package, perform the following steps for Android and iOS.

For Android

Add the following permissions to the AndroidManifest.xml file.

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

For iOS

  1. Set your platform to iOS 13.0 or above in your Podfile.
platform :ios, '13.0'
  1. Add the following entries to the Info.plist file. This gives permission to your app to access the camera and microphone, access photos, install the required fonts and icons.
<key>NSBluetoothPeripheralUsageDescription</key>
<string>We will use your Bluetooth to access your Bluetooth headphones.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>We will use your Bluetooth to access your Bluetooth headphones.</string>
<key>NSCameraUsageDescription</key>
<string>For people to see you during meetings, we need access to your camera.</string>
<key>NSMicrophoneUsageDescription</key>
<string>For people to hear you during meetings, we need access to your microphone.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>For people to share, we need access to your photos.</string>

In iOS, if you are allowing user to download attachments in chat, add the following permissions in your app's Info.plist:

<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
Note

If you intend to publish your app to the Google Play or App Store, you'll need to perform a few additional steps. So if you're working on release builds and not debug builds, refer to the Release Builds section.

Step 2: Initialize the SDK

The DyteMobileClient is the main class of the SDK. It is the entry point and the only class required to initialize Dyte SDK.

final dyteClient = DyteMobileClient();

Step 3: Set the meeting properties

Set the properties in the DyteMeetingInfo class. You just need to provide the participant's authToken.

NameDescription
authTokenAfter you've created the meeting,
add each participant to the meeting
using the Add Participant API
(The presetName created earlier
must be passed in the body
of the Add Participant API request)
The API response contains the authToken.
final meetingInfo = DyteMeetingInfoV2(
authToken: '<auth_token>',
);

Step 4: Initialize the connection request

To initialize the connection request, call the init() method obtained on dyteClient with the meetingInfo argument. This will establish the connection with the Dyte meeting server.

dyteClient.init(meetingInfo);

By registering state observers, you receive callbacks for this action on the meeting object.


class RoomStateNotifier implements DyteMeetingRoomEventsListener {

...


void onMeetingInitStarted() {
/// on meeting init started
}

override
void onMeetingInitCompleted() {
/// on meeting init completed
}


void onMeetingInitFailed(Exception exception) {
/// on meeting init failed
}

...
}

Subscibe to the DyteMeetingRoomEventsListener to receive the callbacks for the meeting object.

dyteClient.addMeetingRoomEventsListener(RoomStateNotifier());

Step 5: Connect to the meeting

Now, if you have established the connection with the Dyte meeting server successfully i.e. if you received onMeetingInitCompleted callback, next step is to join the room.

Join the room

To join the meeting room, call joinRoom() method on the dyteClient instance as shown below.

dyteClient.joinRoom();

By registering state observers, you receive callbacks for join related actions on the meeting object.

class RoomStateNotifier implements DyteMeetingRoomEventsListener {

...


void onMeetingRoomJoinStarted() {
/// Handle join start state
}


void onMeetingRoomJoined() {
/// Handle joining completion, ex: move to room screen
}


void onMeetingRoomJoinFailed(exception){
/// Handle failure
}

...
}

Successful joining of meeting is indicated by onMeetingRoomJoined callback.

Leave the room

Once the meeting is over, you can leave the meeting room.

To leave the meeting room, call leaveRoom() method on the dyteClient as shown below.

dyteClient.leaveRoom();

By registering state observers, you receive callbacks for this action on the meeting object.

class RoomStateNotifier implements DyteMeetingRoomEventsListener {

...


void onMeetingRoomLeaveStarted() {
/// on meeting room leave started
}


void onMeetingRoomLeaveCompleted() {
/// on meeting room left
}

...

}

Successfully exiting the meeting is indicated by onMeetingRoomLeaveCompleted callback.

Release Builds

If you intend to publish your app to the Google Play or App Store, perform the following steps after installing the SDKs. So if you're working on release builds and not debug builds, do the following:

For Android release builds

Perform the following steps, for Android release builds:

  1. Create /android/app/proguard-rules.pro file.
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if .serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if .serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}

# keep webrtc classes
-keep class org.webrtc.** { *; }
-dontwarn org.chromium.build.BuildHooksAndroid

# keep ktor classes
-keep class io.ktor.** { *; }

  1. Add the following to your android/app/build.gradle to import the proguard configuration.
buildTypes {
release {
...
...
...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

For iOS release builds

Disable BITCODE in your Podfile.

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end