startMeeting method

  1. @override
Future<List> startMeeting({
  1. required String clientId,
  2. required String clientSecret,
  3. required String accountId,
  4. required MeetingOptions meetingOptions,
})
override

Flutter Zoom SDK Start Meeting function

Implementation

@override
Future<List> startMeeting({
  required String clientId,
  required String clientSecret,
  required String accountId,
  required MeetingOptions meetingOptions,
}) async {
  try {
    // Prepare options map
    final options = <String, dynamic>{
      ZoomConstants.MEETING_ID: meetingOptions.meetingId ?? '',
      ZoomConstants.USER_ID: meetingOptions.userId ?? '',
      ZoomConstants.DISPLAY_NAME: meetingOptions.displayName ?? '',
      ZoomConstants.USER_PASSWORD: meetingOptions.userPassword ?? '',
      ZoomConstants.DISABLE_DIAL_IN: meetingOptions.noDialInViaPhone ?? '',
      ZoomConstants.DISABLE_DRIVE: meetingOptions.noDrivingMode ?? '',
      ZoomConstants.DISABLE_INVITE: meetingOptions.noInvite ?? '',
      ZoomConstants.DISABLE_SHARE: meetingOptions.noShare ?? '',
      ZoomConstants.DISABLE_TITLEBAR: meetingOptions.noTitlebar ?? '',
      ZoomConstants.VIEW_OPTIONS: meetingOptions.viewOptions ?? '',
      ZoomConstants.NO_DISCONNECT_AUDIO:
          meetingOptions.noDisconnectAudio ?? '',
      ZoomConstants.NO_AUDIO: meetingOptions.noAudio ?? '',
      ZoomConstants.USER_TYPE: meetingOptions.userType ?? '',
    };

    // Instantiate ZoomProvider and ZoomRepository
    final ZoomProvider zoomProvider = ZoomProvider();
    final ZoomRepository repository =
        ZoomRepository(zoomProvider: zoomProvider);

    // Fetch access token
    final AccessTokenModel accessTokenResponse =
        await repository.fetchAccesstoken(
      accountId: accountId,
      clientId: clientId,
      clientSecret: clientSecret,
    );

    // Fetch zak token
    final String zakTokenResponse = await repository.fetchZaktoken(
      clientId: clientId,
      clientSecret: clientSecret,
      accessToken: accessTokenResponse.accessToken,
    );

    // Add zak token to options map
    options
        .addAll(<String, dynamic>{ZoomConstants.ZAK_TOKEN: zakTokenResponse});

    print("zak $zakTokenResponse");

    // Invoke method and handle the result
    final version = await methodChannel.invokeMethod<List>(
      ZoomConstants.START_MEETING,
      options,
    );

    // Use null coalescing operator to return an empty list if null
    return version ?? [];
  } catch (e) {
    // Throw a custom error to provide a meaningful error message
    throw ZoomError('Error starting meeting: $e');
  }
}