overlap_stack 2.0.0
overlap_stack: ^2.0.0 copied to clipboard
Intelligently stacks your widgets, allowing them to partially overlap for a compact and visually interesting layout.
import 'package:flutter/material.dart';
import 'package:overlap_stack/overlap_stack.dart';
void main() {
runApp(const OverlapStackDemoApp());
}
class OverlapStackDemoApp extends StatelessWidget {
const OverlapStackDemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'OverlapStack Showcase',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF6366F1),
brightness: Brightness.light,
),
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF6366F1),
brightness: Brightness.dark,
),
useMaterial3: true,
),
themeMode: ThemeMode.system,
home: const DemoHomeScreen(),
);
}
}
class DemoHomeScreen extends StatefulWidget {
const DemoHomeScreen({super.key});
@override
State<DemoHomeScreen> createState() => _DemoHomeScreenState();
}
class _DemoHomeScreenState extends State<DemoHomeScreen> {
int _selectedTabIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('OverlapStack Demo & Gallery'),
elevation: 0,
bottom: PreferredSize(
preferredSize: const Size.fromHeight(48),
child: NavigationBar(
selectedIndex: _selectedTabIndex,
onDestinationSelected: (idx) => setState(() => _selectedTabIndex = idx),
height: 48,
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
destinations: const [
NavigationDestination(
icon: Icon(Icons.tune),
label: 'Playground',
),
NavigationDestination(
icon: Icon(Icons.people_alt_outlined),
label: 'Real-World UI',
),
NavigationDestination(
icon: Icon(Icons.layers_outlined),
label: 'Z-Order',
),
NavigationDestination(
icon: Icon(Icons.view_carousel_outlined),
label: 'Cards & Vertical',
),
],
),
),
),
body: IndexedStack(
index: _selectedTabIndex,
children: const [
PlaygroundTab(),
RealWorldPatternsTab(),
ZOrderGalleryTab(),
CardsAndVerticalTab(),
],
),
);
}
}
// ---------------------------------------------------------------------------
// TAB 1: INTERACTIVE PLAYGROUND
// ---------------------------------------------------------------------------
class PlaygroundTab extends StatefulWidget {
const PlaygroundTab({super.key});
@override
State<PlaygroundTab> createState() => _PlaygroundTabState();
}
class _PlaygroundTabState extends State<PlaygroundTab> {
Axis _direction = Axis.horizontal;
OverlapStackAlign _align = OverlapStackAlign.center;
int _leadIndex = -1;
double _minSpacing = 0.5;
double _maxSpacing = 0.8;
int _itemCount = 18;
int _itemLimit = -1;
double _containerExtent = 380.0;
bool _enableInfo = true;
final List<Color> _palette = const [
Color(0xFFEF4444),
Color(0xFFF97316),
Color(0xFFF59E0B),
Color(0xFF10B981),
Color(0xFF06B6D4),
Color(0xFF3B82F6),
Color(0xFF6366F1),
Color(0xFF8B5CF6),
Color(0xFFEC4899),
];
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final isHoriz = _direction == Axis.horizontal;
return SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 800),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Live Demo Viewport
Card(
elevation: 0,
color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Live Canvas (${isHoriz ? "Width" : "Height"}: ${_containerExtent.round()}px)',
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
Chip(
label: Text(
'${_direction.name.toUpperCase()} • ${_align.name.toUpperCase()}',
style: const TextStyle(fontSize: 11),
),
),
],
),
const SizedBox(height: 24),
Container(
width: isHoriz ? _containerExtent : 100,
height: isHoriz ? 70 : _containerExtent,
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: colorScheme.primary.withValues(alpha: 0.3),
width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
alignment: Alignment.center,
child: OverlapStack.builder(
direction: _direction,
align: _align,
minSpacing: _minSpacing,
maxSpacing: _maxSpacing,
leadIndex: _leadIndex,
itemLimit: _itemLimit,
itemCount: _itemCount,
itemSize: const Size.square(46),
itemBuilder: (context, i) {
final color = _palette[i % _palette.length];
return Container(
width: 46,
height: 46,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: color,
border: Border.all(
color: colorScheme.surface,
width: 2.5,
),
),
alignment: Alignment.center,
child: Text(
'${i + 1}',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
);
},
infoBuilder: _enableInfo
? (context, remaining) {
return Container(
width: 46,
height: 46,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: colorScheme.primaryContainer,
border: Border.all(
color: colorScheme.surface,
width: 2.5,
),
),
alignment: Alignment.center,
child: Text(
'+$remaining',
style: TextStyle(
color: colorScheme.onPrimaryContainer,
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
);
}
: null,
),
),
],
),
),
),
const SizedBox(height: 24),
// Controls Panel
Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Layout Controls',
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
// Container Extent Slider
Text('Container Size: ${_containerExtent.round()}px'),
Slider(
value: _containerExtent,
min: 80,
max: 700,
onChanged: (v) => setState(() => _containerExtent = v),
),
// Direction & Alignment
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Direction:'),
const SizedBox(height: 6),
SegmentedButton<Axis>(
segments: const [
ButtonSegment(
value: Axis.horizontal,
label: Text('Horizontal'),
icon: Icon(Icons.swap_horiz),
),
ButtonSegment(
value: Axis.vertical,
label: Text('Vertical'),
icon: Icon(Icons.swap_vert),
),
],
selected: {_direction},
onSelectionChanged: (val) {
setState(() => _direction = val.first);
},
),
],
),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Align:'),
const SizedBox(height: 6),
SegmentedButton<OverlapStackAlign>(
segments: const [
ButtonSegment(
value: OverlapStackAlign.start,
label: Text('Start'),
),
ButtonSegment(
value: OverlapStackAlign.center,
label: Text('Center'),
),
ButtonSegment(
value: OverlapStackAlign.end,
label: Text('End'),
),
],
selected: {_align},
onSelectionChanged: (val) {
setState(() => _align = val.first);
},
),
],
),
),
],
),
const SizedBox(height: 16),
// Lead Index & Info
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Lead Index (Z-Order):'),
const SizedBox(height: 6),
SegmentedButton<int>(
segments: const [
ButtonSegment(
value: -1,
label: Text('Last (-1)'),
),
ButtonSegment(
value: 0,
label: Text('First (0)'),
),
ButtonSegment(
value: 3,
label: Text('Apex (3)'),
),
],
selected: {_leadIndex},
onSelectionChanged: (val) {
setState(() => _leadIndex = val.first);
},
),
],
),
),
const SizedBox(width: 16),
Expanded(
child: SwitchListTile(
title: const Text('Show +N Info'),
value: _enableInfo,
onChanged: (val) => setState(() => _enableInfo = val),
),
),
],
),
const SizedBox(height: 16),
// Spacing Range
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Min Spacing (${_minSpacing.toStringAsFixed(2)})'),
Slider(
value: _minSpacing,
min: 0.1,
max: 0.9,
onChanged: (v) {
setState(() {
_minSpacing = v;
if (_maxSpacing < _minSpacing) {
_maxSpacing = _minSpacing;
}
});
},
),
],
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Max Spacing (${_maxSpacing.toStringAsFixed(2)})'),
Slider(
value: _maxSpacing,
min: _minSpacing,
max: 1.0,
onChanged: (v) => setState(() => _maxSpacing = v),
),
],
),
),
],
),
// Item count & limit
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Total Items: $_itemCount'),
Slider(
value: _itemCount.toDouble(),
min: 1,
max: 40,
divisions: 39,
onChanged: (v) => setState(() => _itemCount = v.round()),
),
],
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Item Limit: ${_itemLimit == -1 ? "None" : _itemLimit}'),
Slider(
value: _itemLimit.toDouble(),
min: -1,
max: 20,
divisions: 21,
onChanged: (v) => setState(() => _itemLimit = v.round()),
),
],
),
),
],
),
],
),
),
),
],
),
),
),
);
}
}
// ---------------------------------------------------------------------------
// TAB 2: REAL-WORLD PATTERNS
// ---------------------------------------------------------------------------
class UserProfile {
final String name;
final String role;
final Color color;
const UserProfile({
required this.name,
required this.role,
required this.color,
});
}
class RealWorldPatternsTab extends StatelessWidget {
const RealWorldPatternsTab({super.key});
static const List<UserProfile> members = [
UserProfile(name: 'Sarah Connor', role: 'Lead Architect', color: Color(0xFF6366F1)),
UserProfile(name: 'Alex Rivera', role: 'Backend Engineer', color: Color(0xFF10B981)),
UserProfile(name: 'David Kim', role: 'UI/UX Designer', color: Color(0xFFF59E0B)),
UserProfile(name: 'Elena Rostova', role: 'Product Manager', color: Color(0xFFEC4899)),
UserProfile(name: 'Marcus Brody', role: 'DevOps Lead', color: Color(0xFF06B6D4)),
UserProfile(name: 'Chloe Zhang', role: 'QA Engineer', color: Color(0xFF8B5CF6)),
UserProfile(name: 'Liam Vance', role: 'Data Scientist', color: Color(0xFFEF4444)),
UserProfile(name: 'Grace Hopper', role: 'Advisor', color: Color(0xFF14B8A6)),
];
void _showAllMembersSheet(BuildContext context) {
showModalBottomSheet<void>(
context: context,
showDragHandle: true,
builder: (ctx) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Project Contributors (${members.length})',
style: Theme.of(ctx).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 12),
Flexible(
child: ListView.separated(
shrinkWrap: true,
itemCount: members.length,
separatorBuilder: (_, __) => const Divider(height: 1),
itemBuilder: (ctx, i) {
final m = members[i];
return ListTile(
leading: CircleAvatar(
backgroundColor: m.color,
child: Text(
m.name[0],
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
),
title: Text(m.name, style: const TextStyle(fontWeight: FontWeight.w600)),
subtitle: Text(m.role),
trailing: const Icon(Icons.check_circle, size: 18, color: Colors.green),
);
},
),
),
],
),
),
);
},
);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
return SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 800),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Production Patterns',
style: theme.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
Text(
'Realistic integrations with high-contrast ring borders, interactive click actions, tooltips, and overflow bottom sheets.',
style: theme.textTheme.bodyMedium?.copyWith(color: colorScheme.outline),
),
const SizedBox(height: 24),
// Pattern 1: Production Avatar Facepile with Tap & Sheet
Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Active Reviewers (Tap avatar or +N)',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
TextButton.icon(
onPressed: () => _showAllMembersSheet(context),
icon: const Icon(Icons.group, size: 16),
label: const Text('View All'),
),
],
),
const SizedBox(height: 16),
SizedBox(
height: 48,
child: OverlapStack.builder(
itemCount: members.length,
itemLimit: 5,
itemSize: const Size.square(44),
minSpacing: 0.55,
maxSpacing: 0.75,
align: OverlapStackAlign.start,
leadIndex: 0, // First on top (Slack/GitHub style)
itemBuilder: (context, i) {
final m = members[i];
return Tooltip(
message: '${m.name} • ${m.role}',
child: InkWell(
onTap: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Selected reviewer: ${m.name}')),
);
},
customBorder: const CircleBorder(),
child: Container(
width: 44,
height: 44,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: m.color,
border: Border.all(
color: colorScheme.surface,
width: 2.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
alignment: Alignment.center,
child: Text(
m.name.split(' ').map((s) => s[0]).take(2).join(),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
),
),
);
},
infoBuilder: (context, remaining) {
return Tooltip(
message: 'View $remaining more contributors',
child: InkWell(
onTap: () => _showAllMembersSheet(context),
customBorder: const CircleBorder(),
child: Container(
width: 44,
height: 44,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: colorScheme.primaryContainer,
border: Border.all(
color: colorScheme.surface,
width: 2.5,
),
),
alignment: Alignment.center,
child: Text(
'+$remaining',
style: TextStyle(
color: colorScheme.onPrimaryContainer,
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
),
),
);
},
),
),
],
),
),
),
const SizedBox(height: 20),
// Pattern 2: Inside a ListTile & Task Card (Unconstrained layout)
Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Unconstrained ListTile Integration',
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
const Text(
'OverlapStack embedded in ListTile without rigid parent constraints.',
style: TextStyle(fontSize: 13),
),
const SizedBox(height: 16),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
tileColor: colorScheme.surfaceContainerHighest.withValues(alpha: 0.3),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
leading: CircleAvatar(
backgroundColor: colorScheme.primary,
child: const Icon(Icons.rocket_launch, color: Colors.white, size: 20),
),
title: const Text(
'Sprint 42: Modernize Core',
style: TextStyle(fontWeight: FontWeight.w600),
),
subtitle: const Text('Due in 3 days • High Priority'),
trailing: SizedBox(
width: 110,
child: OverlapStack.builder(
itemCount: members.length,
itemLimit: 3,
itemSize: const Size.square(32),
minSpacing: 0.6,
maxSpacing: 0.6,
align: OverlapStackAlign.end,
itemBuilder: (context, i) {
return CircleAvatar(
radius: 16,
backgroundColor: members[i].color,
child: Text(
members[i].name[0],
style: const TextStyle(fontSize: 10, color: Colors.white),
),
);
},
infoBuilder: (context, remaining) {
return CircleAvatar(
radius: 16,
backgroundColor: colorScheme.surfaceContainerHighest,
child: Text(
'+$remaining',
style: TextStyle(fontSize: 10, color: colorScheme.onSurface),
),
);
},
),
),
),
],
),
),
),
],
),
),
),
);
}
}
// ---------------------------------------------------------------------------
// TAB 3: Z-ORDER GALLERY (LEAD INDEX)
// ---------------------------------------------------------------------------
class ZOrderGalleryTab extends StatelessWidget {
const ZOrderGalleryTab({super.key});
final List<Color> _colors = const [
Color(0xFFEF4444),
Color(0xFF3B82F6),
Color(0xFF10B981),
Color(0xFFF59E0B),
Color(0xFF8B5CF6),
];
Widget _buildDemoRow({
required BuildContext context,
required String title,
required String description,
required int leadIndex,
}) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
return Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
Chip(
label: Text(
'leadIndex: $leadIndex',
style: const TextStyle(fontSize: 12, fontFamily: 'monospace'),
),
),
],
),
const SizedBox(height: 4),
Text(description, style: TextStyle(color: colorScheme.outline, fontSize: 13)),
const SizedBox(height: 20),
Center(
child: SizedBox(
width: 260,
height: 60,
child: OverlapStack.builder(
leadIndex: leadIndex,
itemCount: _colors.length,
itemSize: const Size.square(52),
minSpacing: 0.55,
maxSpacing: 0.55,
align: OverlapStackAlign.center,
itemBuilder: (context, i) {
final isLead = (leadIndex == -1 && i == _colors.length - 1) ||
(leadIndex == 0 && i == 0) ||
(leadIndex == i);
return Container(
width: 52,
height: 52,
decoration: BoxDecoration(
color: _colors[i],
shape: BoxShape.circle,
border: Border.all(
color: isLead ? Colors.white : colorScheme.surface,
width: isLead ? 3.5 : 2.0,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: isLead ? 0.35 : 0.15),
blurRadius: isLead ? 8 : 4,
offset: const Offset(0, 3),
),
],
),
alignment: Alignment.center,
child: Text(
'#${i + 1}',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
);
},
),
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 800),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_buildDemoRow(
context: context,
title: 'Natural: Last Item on Top',
description:
'Default behavior. Items overlap naturally from left to right, with each subsequent item covering the prior.',
leadIndex: -1,
),
const SizedBox(height: 16),
_buildDemoRow(
context: context,
title: 'Priority: First Item on Top',
description:
'The very first item stays in the foreground. Subsequent items slide behind the previous one.',
leadIndex: 0,
),
const SizedBox(height: 16),
_buildDemoRow(
context: context,
title: 'Apex: Center Stage on Top',
description:
'Item #3 is the apex. Items to the left and right slope backwards behind the center item.',
leadIndex: 2,
),
],
),
),
),
);
}
}
// ---------------------------------------------------------------------------
// TAB 4: CARDS & VERTICAL
// ---------------------------------------------------------------------------
class CardsAndVerticalTab extends StatelessWidget {
const CardsAndVerticalTab({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
return SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 800),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Vertical Notification Stack
Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Vertical Notification Deck',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
const SizedBox(height: 6),
Text(
'Stacked vertically with Axis.vertical for notification summaries or card decks.',
style: TextStyle(color: colorScheme.outline, fontSize: 13),
),
const SizedBox(height: 20),
Center(
child: Container(
width: 320,
height: 240,
padding: const EdgeInsets.all(8),
child: OverlapStack.builder(
direction: Axis.vertical,
leadIndex: 0, // Top card in front
minSpacing: 0.45,
maxSpacing: 0.5,
itemCount: 4,
itemSize: const Size(300, 75),
itemBuilder: (context, i) {
final titles = [
'Deployment Successful',
'New Security Alert',
'Database Backup Ready',
'Meeting in 15 Minutes',
];
final colors = [
Colors.teal,
Colors.amber.shade800,
Colors.indigo,
Colors.deepOrange,
];
return Card(
margin: EdgeInsets.zero,
elevation: (4 - i).toDouble(),
color: colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: colors[i].withValues(alpha: 0.5), width: 1.5),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
children: [
CircleAvatar(
radius: 18,
backgroundColor: colors[i].withValues(alpha: 0.15),
child: Icon(Icons.notifications_active, color: colors[i], size: 18),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
titles[i],
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
),
Text(
'${(i + 1) * 5}m ago',
style: TextStyle(color: colorScheme.outline, fontSize: 11),
),
],
),
),
],
),
),
);
},
),
),
),
],
),
),
),
const SizedBox(height: 20),
// Playing Cards Hand
Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: colorScheme.outlineVariant),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Playing Cards / Poker Hand',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
const SizedBox(height: 6),
Text(
'Non-circular rectangular widgets overlapping with custom aspect ratio.',
style: TextStyle(color: colorScheme.outline, fontSize: 13),
),
const SizedBox(height: 20),
Center(
child: SizedBox(
width: 320,
height: 120,
child: OverlapStack.builder(
itemCount: 5,
itemSize: const Size(70, 105),
minSpacing: 0.65,
maxSpacing: 0.7,
leadIndex: 0,
align: OverlapStackAlign.center,
itemBuilder: (context, i) {
final ranks = ['A', 'K', 'Q', 'J', '10'];
final suits = ['♠', '♥', '♦', '♣', '♠'];
final isRed = i == 1 || i == 2;
return Container(
width: 70,
height: 105,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.black26),
boxShadow: const [
BoxShadow(
color: Colors.black12,
blurRadius: 6,
offset: Offset(0, 3),
),
],
),
padding: const EdgeInsets.all(6),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${ranks[i]}${suits[i]}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: isRed ? Colors.red : Colors.black,
),
),
Center(
child: Text(
suits[i],
style: TextStyle(
fontSize: 28,
color: isRed ? Colors.red : Colors.black,
),
),
),
Align(
alignment: Alignment.bottomRight,
child: Text(
ranks[i],
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: isRed ? Colors.red : Colors.black,
),
),
),
],
),
);
},
),
),
),
],
),
),
),
],
),
),
),
);
}
}