Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/animation.dart';
- void main() {
- runApp(new MaterialApp(
- home: new MyApp(),
- ));
- }
- class MyApp extends StatefulWidget {
- @override
- _State createState() => new _State();
- }
- class _State extends State<MyApp> with TickerProviderStateMixin {
- Animation<double> animation;
- AnimationController controller;
- static final _opacityTween = new Tween<double>(begin: 0.1, end: 1.0);
- static final _sizeTween = new Tween<double>(begin: 0.0, end: 300.0);
- initState() {
- super.initState();
- controller = new AnimationController(duration: const Duration(milliseconds: 2000), vsync: this);
- animation = new CurvedAnimation(parent: controller, curve: Curves.easeIn);
- animation.addStatusListener(listener);
- controller.forward();
- }
- void listener(AnimationStatus status) {
- if(status == AnimationStatus.completed) {
- controller.reverse();
- } else if (status == AnimationStatus.dismissed) {
- controller.forward();
- }
- }
- @override
- Widget build(BuildContext context) {
- print(_opacityTween.evaluate(animation));
- return new Scaffold(
- appBar: new AppBar(
- title: new Text('Name here'),
- ),
- body: new Container(
- padding: new EdgeInsets.all(32.0),
- child: new Center(
- child: new Opacity(
- opacity: _opacityTween.evaluate(animation),
- child: new Container(
- margin: new EdgeInsets.symmetric(vertical: 10.0),
- height: _sizeTween.evaluate(animation),
- width: _sizeTween.evaluate(animation),
- child: new FlutterLogo(),
- ),
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement