Code
// FlockUI Component: Avatar (Badge)
// Description: A circular avatar with an online/offline status indicator dot.
// Category: Elements
// External Dependencies: none
//
// This is a template component. When creating new components, follow this structure:
// 1. Add header comments describing your component
// 2. The class must extend `StatefulWidget` — you can name it anything you like
// 3. If using external packages, list them in the header comments above
// 4. Keep the entire component in a single .dart file
import 'package:flutter/material.dart';
class BadgeAvatar extends StatefulWidget {
const BadgeAvatar({super.key});
@override
State<BadgeAvatar> createState() => _BadgeAvatarState();
}
class _BadgeAvatarState extends State<BadgeAvatar> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SizedBox(
width: 260,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Avatar with status badge
Stack(
children: [
CircleAvatar(
radius: 40,
backgroundColor: theme.colorScheme.tertiaryContainer,
child: Text(
'SH',
style: theme.textTheme.headlineMedium?.copyWith(
color: theme.colorScheme.onTertiaryContainer,
fontWeight: FontWeight.w600,
),
),
),
// Online status dot
Positioned(
right: 2,
bottom: 2,
child: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
color: const Color(0xFF22C55E),
shape: BoxShape.circle,
border: Border.all(
color: theme.colorScheme.surface,
width: 2.5,
),
),
),
),
],
),
const SizedBox(height: 12),
// Name
Text(
'Sonu Hansda',
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 2),
// Status
Text(
'Online',
style: theme.textTheme.bodySmall?.copyWith(
color: const Color(0xFF22C55E),
fontWeight: FontWeight.w600,
),
),
],
),
),
);
}
}
Preview