dyte_core

Logo

Dyte Flutter Core

A SDK that provides Dyte's audio, video conferencing and livestreaming functionality.
Explore the docs »

· Report Bug · Request Feature

Before Getting Started

Installation

flutter pub add dyte_core

For iOS

  1. Set your platform to iOS 12.0 or above in your Podfile.
platform :ios, '12.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>

Usage

Import the following package into your project:

import 'package:dyte_core/dyte_core.dart';

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();

Set the meeting properties

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

Name Description
authToken After 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>',
                  );

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 extends DyteMeetingRoomEventsListener {

  ...

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

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

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

  ...
}

Connect to the meeting

Now, you have established the connection with the Dyte meeting server successfully. 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 this action on the meeting object.

class LocalUserStatesNotifier extends DyteSelfEventsListener {

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

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

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

}

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();

Cleanup listeners

Introduced in dyte_core: 0.3.6, cleanAllNativeListeners() method which needs to be called when you're done with current session of dyte meeting. It interally calls individual new clean methods for each listener cleanNativeMeetingRoomEventsListener(), cleanNativeParticipantEventListener(), cleanNativePollListener(), cleanNativeRecordingListener(), cleanNativeStageEventsListener(), cleanNativeSelfParticipantEventListener(), cleanNativeChatListener(), cleanNativeDataUpdateListener(), cleanNativeLivestreamListener(), cleanNativePluginEventsListener().

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

class RoomStateNotifier extends DyteMeetingRoomEventsListener {

  ...

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

  @override
  void onMeetingRoomLeaveCompleted() {
    dyteClient.removeMeetingRoomEventsListener(this);
    dyteClient.cleanupAppListeners();

    /// on meeting room left
  }

  ...

}

For more examples, please refer to the Documentation.

About

dyte_core is created & maintained by Dyte, Inc. You can find us on Twitter - @dyte_io or write to us at dev@dyte.io.

The names and logos for Dyte are trademarks of Dyte, Inc.

We love open source software! See our other projects and our products.

Libraries

dyte_core