import 'package:flutter/material.dart';
import 'package:zego_uikit_prebuilt_call/zego_uikit_prebuilt_call.dart';
class VideoCallScreen extends StatefulWidget {
const VideoCallScreen({
super.key,
});
@override
State<VideoCallScreen> createState() => _VideoCallScreenState();
}
class _VideoCallScreenState extends State<VideoCallScreen> {
String? userId = DateTime.now().microsecondsSinceEpoch.toString();
String? userName = DateTime.now().toString();
@override
Widget build(BuildContext context) {
return ZegoUIKitPrebuiltCall(
appID: '',
appSign:
'',
userID: userId!,
userName: userName!,
callID: 'demo_call_id_for_testing',
config: ZegoUIKitPrebuiltCallConfig.oneOnOneVideoCall(),
);
}
}
Chat_screen:
Widget appBar() {
return InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ViewProfileScreen(user: widget.user),
),
);
},
child: Expanded(
child: StreamBuilder(
stream: APIs.getUserInfo(widget.user),
builder: (context, snapshot) {
final data = snapshot.data?.docs;
final list =
data?.map((e) => ChatUser.fromJson(e.data())).toList() ?? [];
return Row(
children: [
IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.arrow_back, color: Colors.black54)),
ClipRRect(
borderRadius: BorderRadius.circular(mq.height * .03),
child: CachedNetworkImage(
width: mq.height * .05,
height: mq.height * .05,
imageUrl:
list.isNotEmpty ? list[0].image : widget.user.image,
errorWidget: (context, url, error) =>
const CircleAvatar(child: Icon(CupertinoIcons.person)),
),
),
const SizedBox(width: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
list.isNotEmpty ? list[0].name : widget.user.name,
style: const TextStyle(
fontSize: 16,
color: Colors.black87,
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
list.isNotEmpty
? list[0].isOnline
? 'Online'
: MyDateUtil.getLastActiveTime(
context: context,
lastActive: list[0].lastActive)
: MyDateUtil.getLastActiveTime(
context: context,
lastActive: widget.user.lastActive),
style: const TextStyle(
fontSize: 13, color: Colors.black54),
),
],
),
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const AudioCallScreen(),
),
);
},
icon: const Icon(
Icons.phone,
color: Colors.black,
),
),
IconButton(
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const VideoCallScreen(),
),
);
},
icon: const Icon(Icons.videocam, color: Colors.black),
),
],
);
},
),
),
);
}
``
When i press the audio and video call icon it is connecting with the user whom i want to reach, but as for now it is connecting when the user touches the video and audio icon button. I need it should behave when i touch the video or audio call icon button it should gives signal to the user whom i'm trying to reach for video call and the signal should be two buttons Answer and Decline. same like WhatsApp UI Logic.
You should run your ZegoCloud init function at the launch of your app or after the user logs in. So you could have something like:
This will initialise the user to your ZegoCloud service, allowing ZegoCloud to send invitations to the user device by their userID