<p>In this article, I'm going to share code that will help you to fade in and out widgets in flutter using FadeTransition widget.</p> <p>This is how the output of this example is going to look like.</p> <p>; }</p> <p>color: #569cd6;](class color: #4ec9b0;](_MyAnimationState color: #569cd6;](extends color: #4ec9b0;](State color: #569cd6;](with color: #4ec9b0;](SingleTickerProviderStateMixin { color: #569cd6;](late color: #4ec9b0;](AnimationController _controller; color: #569cd6;](late color: #4ec9b0;](Animation _animation; color: #4ec9b0;](double value = color: #b5cea8;](1.0; color: #569cd6;](@override</p> <p>color: #569cd6;](void color: #dcdcaa;](initState() { color: #569cd6;](super.color: #dcdcaa;](initState(); _controller = color: #4ec9b0;](AnimationController( duration: color: #569cd6;](const color: #4ec9b0;](Duration(milliseconds: color: #b5cea8;](500), vsync: color: #569cd6;](this); _animation = color: #4ec9b0;](Tween( begin: color: #b5cea8;](1.0, end: color: #b5cea8;](0.0, ).color: #dcdcaa;](animate(color: #4ec9b0;](CurvedAnimation(parent: _controller, curve: color: #4ec9b0;](Curves.easeIn)); } color: #569cd6;](@override</p> <p id="dcdcaa;](dispose();" color:="" _controller.color:=>color: #569cd6;](void color: #dcdcaa;](dispose() color: #569cd6;](@override</p> <p id="b5cea8;](0.0);" _controller.color:=>color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext context) { color: #c586c0;](return color: #4ec9b0;](Column( mainAxisAlignment: color: #4ec9b0;](MainAxisAlignment.center, children: [ color: #4ec9b0;](FadeTransition( opacity: _animation, child: color: #569cd6;](const color: #4ec9b0;](FlutterLogo( size: color: #b5cea8;](100.0, ), ), color: #569cd6;](const color: #4ec9b0;](SizedBox( height: color: #b5cea8;](20.0, ), color: #4ec9b0;](ElevatedButton( onPressed: () { color: #dcdcaa;](setState(() { value = value == color: #b5cea8;](1 ? color: #b5cea8;](0 : color: #b5cea8;](1; color: #c586c0;](if (value == color: #b5cea8;](0) color: #c586c0;](else }); }, child: color: #569cd6;](const color: #4ec9b0;](Text(color: #ce9178;]('Fade In/Out')) ], ); } } `</p> <p>Hope this example is useful to you.</p> <p>Thanks, Sri</p>
FadeTransition example - fade in and out.
This Article is posted by seven.srikanth at 6/19/2021 2:35:24 PM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: #FadeTransition; #fadein; #fadeout; hide animation;
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter