morphing_sheet 0.2.0
morphing_sheet: ^0.2.0 copied to clipboard
A production-ready multi-stage, gesture-driven, spatially continuous UX sheet with physics-based snapping and morphing fullscreen transitions.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'list_driven_example.dart';
import 'page_driven_example.dart';
void main() {
runApp(const MorphingSheetExampleApp());
}
class MorphingSheetExampleApp extends StatelessWidget {
const MorphingSheetExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Morphing Sheet Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: const Color(0xFF6750A4),
brightness: Brightness.light,
useMaterial3: true,
),
darkTheme: ThemeData(
colorSchemeSeed: const Color(0xFF6750A4),
brightness: Brightness.dark,
useMaterial3: true,
),
home: const DemoHub(),
);
}
}
/// Navigation hub showcasing both sheet modes.
class DemoHub extends StatelessWidget {
const DemoHub({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 32),
Text('Morphing Sheet', style: theme.textTheme.headlineLarge),
const SizedBox(height: 4),
Text(
'v0.2.0',
style: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.primary,
),
),
const SizedBox(height: 8),
Text(
'A context-aware, spatially continuous morphing interaction '
'container with physics-based snapping.',
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.onSurface.withValues(alpha: 0.7),
),
),
const SizedBox(height: 40),
_DemoCard(
icon: Icons.view_carousel_outlined,
title: 'Page-Driven Mode',
subtitle: 'v0.1.x — Horizontal pages with snap points',
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const PageDrivenExamplePage(),
),
),
),
const SizedBox(height: 16),
_DemoCard(
icon: Icons.list_alt_outlined,
title: 'List-Driven Mode',
subtitle:
'v0.2.0 — Item selection with preview & detail morph',
badge: 'NEW',
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const ListDrivenExamplePage(),
),
),
),
],
),
),
),
);
}
}
class _DemoCard extends StatelessWidget {
const _DemoCard({
required this.icon,
required this.title,
required this.subtitle,
required this.onTap,
this.badge,
});
final IconData icon;
final String title;
final String subtitle;
final VoidCallback onTap;
final String? badge;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Card(
elevation: 2,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: theme.colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(16),
),
child: Icon(icon,
size: 28, color: theme.colorScheme.onPrimaryContainer),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(title, style: theme.textTheme.titleMedium),
if (badge != null) ...[
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: theme.colorScheme.primary,
borderRadius: BorderRadius.circular(8),
),
child: Text(
badge!,
style: theme.textTheme.labelSmall?.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.bold,
),
),
),
],
],
),
const SizedBox(height: 4),
Text(
subtitle,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
),
),
Icon(Icons.chevron_right,
color: theme.colorScheme.onSurfaceVariant),
],
),
),
),
);
}
}