left_marquee_example

mail@pastecode.io avatar
unknown
dart
2 years ago
1.2 kB
14
Indexable
Never
import 'package:flutter/material.dart';

class LeftMarqueeExamplePage extends StatefulWidget {
  @override
  State<LeftMarqueeExamplePage> createState() => _LeftMarqueeExamplePageState();
}

class _LeftMarqueeExamplePageState extends State<LeftMarqueeExamplePage> with SingleTickerProviderStateMixin {
  late final AnimationController _controller = AnimationController(
    vsync: this,
    duration: Duration(
      seconds: 10,
    ),
  )..forward();

  late final Animation<Offset> _marqueeAnimation = Tween<Offset>(
    begin: Offset(
      2.0,
      0.0,
    ),
    end: Offset(
      -2.0,
      0.0,
    ),
  ).animate(
    _controller,
  );

  @override
  Widget build(
    BuildContext context,
  ) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "Left Marquee Example",
        ),
      ),
      body: Center(
        child: SlideTransition(
          position: _marqueeAnimation,
          child: Text(
            "420 69 Helicopter Helicopter 69 420",
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}