marquee_transition 1.3.0
marquee_transition: ^1.3.0 copied to clipboard
A smooth, configurable marquee text and widget scrolling transition for Flutter.
import 'package:flutter/material.dart';
import 'package:marquee_transition/marquee_transition.dart';
void main() {
runApp(const MarqueeExampleApp());
}
class MarqueeExampleApp extends StatelessWidget {
const MarqueeExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'MarqueeTransition Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MarqueeShowcasePage(),
);
}
}
class MarqueeShowcasePage extends StatefulWidget {
const MarqueeShowcasePage({super.key});
@override
State<MarqueeShowcasePage> createState() => _MarqueeShowcasePageState();
}
class _MarqueeShowcasePageState extends State<MarqueeShowcasePage> {
final GlobalKey<MarqueeTransitionState> _controllerKey = GlobalKey();
bool _isPaused = false;
int _activeSnapIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('MarqueeTransition Showcases'),
centerTitle: true,
),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 680),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_buildCard(
title: '1. Seamless Continuous Ticker',
subtitle:
'Smooth constant velocity (80 px/s) with custom bullet divider.',
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(12),
),
child: const MarqueeTransition(
velocity: 80,
divider: Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Icon(Icons.circle, size: 8, color: Colors.deepPurple),
),
children: [
Text('🚀 Flutter 3.29 release is here!',
style: TextStyle(fontWeight: FontWeight.bold)),
Text('📦 MarqueeTransition v1.0.0 is now available!'),
Text('⚡ Zero stutter, 60/120fps wrap-around guaranteed!'),
],
),
),
),
const SizedBox(height: 24),
_buildCard(
title: '2. Fading Edge + Pause on Hover',
subtitle:
'Hover your mouse cursor to pause scrolling. Edges fade gently.',
child: Container(
height: 52,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
),
child: MarqueeTransition.text(
'Hover over this text to pause the marquee! When you move the pointer away, the transition resumes seamlessly without jumping.',
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
velocity: 60,
pauseOnHover: true,
fadingEdge: true,
fadingEdgeRatio: 0.12,
),
),
),
const SizedBox(height: 24),
_buildCard(
title: '3. Ping-Pong Mirror Mode with Cards',
subtitle:
'Scrolls back and forth smoothly with custom reverse curve and delays.',
child: Container(
height: 120,
padding: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(12),
),
child: MarqueeTransition(
mirror: true,
velocity: 50,
delay: const Duration(seconds: 1),
reverseDelay: const Duration(seconds: 1),
curve: Curves.easeInOutCubic,
reverseCurve: Curves.easeInOutCubic,
children: List.generate(6, (i) {
return Container(
width: 140,
margin: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.primaries[i % Colors.primaries.length],
Colors.primaries[(i + 3) % Colors.primaries.length],
],
),
borderRadius: BorderRadius.circular(12),
),
alignment: Alignment.center,
child: Text(
'Card #${i + 1}',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
);
}),
),
),
),
const SizedBox(height: 24),
_buildCard(
title: '4. Imperative State Control',
subtitle: 'Control pause, resume, and restart programmatically.',
child: Column(
children: [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.tertiaryContainer,
borderRadius: BorderRadius.circular(12),
),
child: MarqueeTransition(
key: _controllerKey,
pause: _isPaused,
velocity: 70,
children: const [
Text(
'🎮 Imperative Control: Use the buttons below to pause, resume, or restart this ticker!',
style: TextStyle(fontWeight: FontWeight.w600),
),
],
),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton.tonalIcon(
onPressed: () {
setState(() => _isPaused = !_isPaused);
},
icon: Icon(_isPaused ? Icons.play_arrow : Icons.pause),
label: Text(_isPaused ? 'Resume' : 'Pause'),
),
const SizedBox(width: 12),
OutlinedButton.icon(
onPressed: () {
_controllerKey.currentState?.restart();
},
icon: const Icon(Icons.refresh),
label: const Text('Restart'),
),
],
),
],
),
),
const SizedBox(height: 24),
_buildCard(
title: '5. Vertical Alert Ticker + Touch Pause',
subtitle:
'Vertical marquee with gap: 12.0 and pauseOnTouch enabled for touchscreens.',
child: Container(
height: 48,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.errorContainer,
borderRadius: BorderRadius.circular(12),
),
child: const MarqueeTransition(
direction: AxisDirection.down,
velocity: 40,
gap: 12.0,
pauseOnTouch: true,
pauseOnHover: true,
children: [
Text('⚠️ Critical Server Notice: Maintenance scheduled tonight at 02:00 UTC.',
style: TextStyle(fontWeight: FontWeight.bold)),
Text('🔔 Version 1.1.0 update includes accessibility and pauseOnTouch!'),
Text('🛡️ Zero security vulnerabilities detected across all packages.'),
],
),
),
),
const SizedBox(height: 24),
_buildCard(
title: '6. Single-Child Snap Banner (v1.3.0 fillViewport)',
subtitle:
'Each item occupies 100% viewport width without truncation or edge overflow.',
child: Column(
children: [
Container(
height: 64,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(12),
),
child: MarqueeTransition(
snap: true,
fillViewport: true,
snapDelay: const Duration(milliseconds: 2500),
snapDuration: const Duration(milliseconds: 600),
snapCurve: Curves.easeInOutCubic,
gap: 24.0,
pauseOnHover: true,
pauseOnTouch: true,
onSnap: (index) {
setState(() => _activeSnapIndex = index);
},
children: const [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.flash_on, color: Colors.amber),
SizedBox(width: 8),
Text('Step 1: Ultra-fast 60/120fps stepped transitions',
style: TextStyle(fontWeight: FontWeight.bold)),
],
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.timer_outlined, color: Colors.blue),
SizedBox(width: 8),
Text('Step 2: Configurable pause delay per child item',
style: TextStyle(fontWeight: FontWeight.bold)),
],
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.touch_app_outlined, color: Colors.green),
SizedBox(width: 8),
Text('Step 3: Seamless wrap-around & pause-on-touch support',
style: TextStyle(fontWeight: FontWeight.bold)),
],
),
],
),
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(3, (i) {
final isActive = _activeSnapIndex == i;
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
margin: const EdgeInsets.symmetric(horizontal: 4),
width: isActive ? 24 : 8,
height: 8,
decoration: BoxDecoration(
color: isActive
? Theme.of(context).colorScheme.primary
: Colors.grey.shade400,
borderRadius: BorderRadius.circular(4),
),
);
}),
),
],
),
),
const SizedBox(height: 24),
_buildCard(
title: '7. Vertical News Snap Flipper (v1.3.0)',
subtitle:
'Vertical announcement ticker flipping one item at a time with fillViewport.',
child: Container(
height: 52,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(12),
),
child: const MarqueeTransition(
direction: AxisDirection.down,
snap: true,
fillViewport: true,
snapDelay: Duration(seconds: 2),
snapDuration: Duration(milliseconds: 500),
snapCurve: Curves.easeInOutCubic,
pauseOnHover: true,
pauseOnTouch: true,
children: [
Row(
children: [
Icon(Icons.trending_up, color: Colors.teal),
SizedBox(width: 8),
Text('Market alert: Indices rally to new all-time high',
style: TextStyle(fontWeight: FontWeight.w600)),
],
),
Row(
children: [
Icon(Icons.system_update_alt, color: Colors.orange),
SizedBox(width: 8),
Text('Release notice: v1.3.0 snap & fillViewport is live',
style: TextStyle(fontWeight: FontWeight.w600)),
],
),
Row(
children: [
Icon(Icons.shield_outlined, color: Colors.indigo),
SizedBox(width: 8),
Text('Security status: All verification tests passing',
style: TextStyle(fontWeight: FontWeight.w600)),
],
),
],
),
),
),
],
),
),
),
),
);
}
Widget _buildCard({
required String title,
required String subtitle,
required Widget child,
}) {
return Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: Colors.grey.shade300),
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
),
const SizedBox(height: 4),
Text(
subtitle,
style: TextStyle(fontSize: 13, color: Colors.grey.shade700),
),
const SizedBox(height: 16),
child,
],
),
),
);
}
}