call method
Future<Map<String, dynamic> >
call(
- BuildContext context, {
- required CallType callType,
- required List<
String> userIdList, - String? chatGroupId,
- String? roomId,
- String? userData,
- Map<
String, dynamic> ? offlinePushInfo,
override
Implementation
@override
Future<Map<String, dynamic>> call(BuildContext context, { required CallType callType, required List<String> userIdList, String? chatGroupId, String? roomId, String? userData, Map<String, dynamic>? offlinePushInfo }) async {
if (userIdList.isEmpty) {
throw Exception('拨打对方的 userId 列表为空,需要传入非空的 userIdList 参数');
}
if (ImState.callTypeNotifier.value != null) {
throw Exception('正在通话中,不可重复拨打');
}
ImState.callTypeNotifier.value = callType;
if (context.mounted) {
showCallOverlay(context, callId: 'inviting');
}
ImState.updateCallMemberList(userIdList);
ImState.callIsInitiatorNotifier.value = true;
try {
final result = await _pluginCall.startCalls(userIdList.join('|'), callType.name, chatGroupId ?? '', roomId ?? '', userData ?? '', (offlinePushInfo ?? {}).jsify() as JSObject).toDart;
final rawData = result.dartify() as Map?;
return Map<String, dynamic>.from(rawData ?? {});
} catch (e) {
hideCallOverlay();
throw Exception('发起音视频通话邀请失败: $e');
}
}