interactive_modal 0.0.1
interactive_modal: ^0.0.1 copied to clipboard
A Flutter package for displaying interactive modals over background content while maintaining full interactivity with both. Features draggable modals, customizable positioning, and smooth animations.
import 'package:example/draggable_example.dart';
import 'package:flutter/material.dart';
import 'travel_map_example.dart';
import 'simple_example.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Interactive Modal Examples',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF2D545E),
brightness: Brightness.light,
),
useMaterial3: true,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Theme.of(context).colorScheme.primary,
Theme.of(context).colorScheme.primary.withValues(alpha: 0.7),
Theme.of(context).colorScheme.secondary,
],
),
),
child: SafeArea(
child: Column(
children: [
const SizedBox(height: 60),
// Header
const Icon(
Icons.layers_rounded,
size: 80,
color: Colors.white,
),
const SizedBox(height: 20),
const Text(
'Interactive Modal',
style: TextStyle(
fontSize: 36,
fontWeight: FontWeight.bold,
color: Colors.white,
letterSpacing: 1.2,
),
),
const SizedBox(height: 10),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
'Explore the interactive examples',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Colors.white70,
letterSpacing: 0.5,
),
),
),
const SizedBox(height: 60),
// Examples Grid
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ListView(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildExampleCard(
context,
title: 'Simple Example',
description:
'Basic interaction with modal and simultaneous background',
icon: Icons.touch_app_rounded,
gradient: LinearGradient(
colors: [
const Color(0xFF66A5AD),
const Color(0xFF66A5AD)
.withValues(alpha: 0.7),
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SimplePage(),
),
);
},
),
const SizedBox(height: 24),
_buildExampleCard(
context,
title: 'Travel Map',
description:
'Visualize an animated route with interactive controls',
icon: Icons.map_rounded,
gradient: LinearGradient(
colors: [
const Color(0xFF66A5AD),
const Color(0xFF66A5AD)
.withValues(alpha: 0.7),
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const TravelMapExample(),
),
);
},
),
const SizedBox(height: 24),
_buildExampleCard(
context,
title: 'Draggable Modal',
description:
'Move the modal around while keeping background interactive',
icon: Icons.open_with_rounded,
gradient: LinearGradient(
colors: [
const Color(0xFF66A5AD),
const Color(0xFF66A5AD)
.withValues(alpha: 0.7),
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const DraggableExample(),
),
);
},
),
],
),
],
)),
),
],
),
),
),
);
}
Widget _buildExampleCard(
BuildContext context, {
required String title,
required String description,
required IconData icon,
required Gradient gradient,
required VoidCallback onTap,
}) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(24),
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
gradient: gradient,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.3),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
icon,
size: 32,
color: Colors.white,
),
),
const Spacer(),
const Icon(
Icons.arrow_forward_rounded,
color: Colors.white,
size: 28,
),
],
),
const SizedBox(height: 20),
Text(
title,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
const SizedBox(height: 8),
Text(
description,
style: TextStyle(
fontSize: 14,
color: Colors.white.withValues(alpha: 0.9),
height: 1.4,
),
),
],
),
),
),
);
}
}