Video Call Screen
Loading preview
Starting the Flutter app
Full-screen video call UI with controls for mute, camera, speaker, and ending call
import 'package:flutter/material.dart';
class VideoCallScreen extends StatefulWidget {
const VideoCallScreen({super.key});
@override
State<VideoCallScreen> createState() => _VideoCallScreenState();
}
class _VideoCallScreenState extends State<VideoCallScreen> {
bool _isMuted = false;
bool _isVideoOn = true;
bool _isSpeakerOn = false;
bool _isFrontCamera = true;
@override
Widget build(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return Scaffold(
backgroundColor: Colors.black,
body: Stack(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: isDark
? [Colors.grey[900]!, Colors.black]
: [Colors.blue[300]!, Colors.blue[700]!],
),
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircleAvatar(
radius: 60,
backgroundColor: Colors.white24,
child: Icon(Icons.person, size: 70, color: Colors.white),
),
const SizedBox(height: 20),
const Text(
'Sarah Johnson',
style: TextStyle(
color: Colors.white,
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
Text(
'00:45:32',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 16,
),
),
],
),
),
),
Positioned(
top: 50,
right: 20,
child: Container(
width: 100,
height: 150,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.white24, width: 2),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: _isVideoOn
? Container(
color: _isFrontCamera
? Colors.grey[800]
: Colors.blueGrey[700],
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
_isFrontCamera ? Icons.person : Icons.landscape,
color: Colors.white54,
),
const SizedBox(height: 4),
Text(
_isFrontCamera ? 'Front' : 'Rear',
style: const TextStyle(
color: Colors.white54,
fontSize: 11,
),
),
],
),
)
: const Center(
child: Icon(Icons.videocam_off, color: Colors.white54),
),
),
),
),
Positioned(
bottom: 50,
left: 0,
right: 0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildControlButton(
icon: _isMuted ? Icons.mic_off : Icons.mic,
label: _isMuted ? 'Unmute' : 'Mute',
isActive: _isMuted,
onTap: () => setState(() => _isMuted = !_isMuted),
),
_buildControlButton(
icon: Icons.call_end,
label: 'End',
isActive: true,
color: Colors.red,
onTap: () => Navigator.pop(context),
),
_buildControlButton(
icon: _isVideoOn ? Icons.videocam : Icons.videocam_off,
label: _isVideoOn ? 'Stop Video' : 'Start Video',
isActive: !_isVideoOn,
onTap: () => setState(() => _isVideoOn = !_isVideoOn),
),
_buildControlButton(
icon: _isSpeakerOn ? Icons.volume_up : Icons.volume_off,
label: 'Speaker',
isActive: _isSpeakerOn,
onTap: () => setState(() => _isSpeakerOn = !_isSpeakerOn),
),
_buildControlButton(
icon: _isFrontCamera ? Icons.camera_front : Icons.camera_rear,
label: 'Flip',
onTap: () => setState(() => _isFrontCamera = !_isFrontCamera),
),
],
),
),
],
),
);
}
Widget _buildControlButton({
required IconData icon,
required String label,
bool isActive = false,
Color? color,
required VoidCallback onTap,
}) {
return GestureDetector(
onTap: onTap,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: isActive
? (color ?? Colors.white).withValues(alpha: 0.3)
: Colors.white.withValues(alpha: 0.2),
shape: BoxShape.circle,
),
child: Icon(icon, color: color ?? Colors.white, size: 28),
),
const SizedBox(height: 8),
Text(
label,
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 12,
),
),
],
),
);
}
}
Add it to your project
Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.
First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.
How it works
There’s no camera or WebRTC code. The remote video is a LinearGradient behind a CircleAvatar, the self-view is a grey box, and ‘00:45:32’ never ticks. _isMuted, _isVideoOn and _isSpeakerOn update the UI. _isFrontCamera switches the Flip button’s icon, and the self-view’s tint, icon and Front or Rear caption, so flipping is visible.
Adapting it
- Replace the background
Containerwith a remote renderer and thePositionedbox with a local preview, for exampleRTCVideoViewfrom flutter_webrtc. - Call your SDK inside each
_buildControlButtononTap, such as switching cameras from Flip. - Run the duration from a
Timer.periodic, and pass the caller’s name intoVideoCallScreen.