title: Flutter FadeIn/FadeOut animation together
body: <p>in this simple sample code i want to have fadeIn and fadeOut animation together, but in this code fadeIn work only and <code>reverse</code> not work, how can i have both of them together?</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main()=&gt;runApp(MaterialApp(home: FadeTransitionSample(),));
  class FadeTransitionSample extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; _Fade();
  }
  
  class _Fade extends State&lt;FadeTransitionSample&gt; with TickerProviderStateMixin {
    AnimationController animation;
    Animation&lt;double&gt; _fadeInFadeOut;
  
    @override
    void initState() {
      super.initState();
      animation = AnimationController(vsync: this, duration: Duration(seconds: 3),);
      _fadeInFadeOut = Tween&lt;double&gt;(begin: 0.0, end: 0.1).animate(animation);
  
      animation.addListener((){
        if(animation.isCompleted){
          animation.reverse();
        }else{
          animation.forward();
        }
      });
      animation.repeat();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Container(
          child: Center(
            child: FadeTransition(
              opacity: animation,
              child: Container(
                color: Colors.green,
                width: 100,
                height: 100,
              ),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>