Flutter Animation Tutorial - Understand the Basics & Animate with Ease
Vložit
- čas přidán 27. 07. 2024
- 📗 Learn from the written tutorial 👇👇
resocoder.com/flutter-animati...
👨💻 Do you write good code? Find out now 👇
resocoder.com/good-code-quiz
Apps are boring! Of course, only until you add good looking animations into them. Since Flutter renders everything to the screen itself without relying on those pesky native views, you can animate literally everything. As they say though, with great power comes great... confusion? In this tutorial, we will dispell this fog surrounding custom animations and you will finally gain clarity in this matter.
Much of the aforementioned confusion stems from the fact that there are many ways to do the same thing. Repeatedly calling setState in a StatefulWidget? Possible. What about extending an AnimatedWidget? Oh, and what's that AnimatedBuilder all about? Let's take a look at them one by one. All of them will be demonstrated on a rotation animation.
Go to the website for more information, code examples, and articles:
● resocoder.com
Follow me on social media:
● / resocoder
● / resocoder
● / resocoder
● gab.ai/resocoder
Fantastic tute! Can't wait for part 2!
Finally got my animation to work thanks to this video! YEAH!
Estaba esperando esto hace rato!!!!! I was waiting for This!!!!!
Watched many tutorials on animation ,but not understand and watched this one,and fully satisfied.Thamks man
best animation introduction ever!!!
I AM TOTALLY CONFUSED. Now I start watching!
Amazing work, even better than the official videos. Thanks a lot for your efforts, will recommend you any time :-)
Can't wait for the next part
Thank you sir, your tutorial is really easy to understand.
Awesome. I like seeing the community trying to clear up the animations api. In my animation video I also show how to use reactHooks to reduce the animation code, as well as the a AnimatedWidget and the SequenceBuilder. Looking forward to part2.
Great stuff! I feel like animations are surrounded with a cloud of mystery for sure.
You are the best teacher for the animation process, easy to follow and can understand it simple ever day language!!!
Simply AWESOME.... no other word but AWESOME... thanks a ton...
Great video. Thank you very much!!
Thanxz by the tutorial!
Great tutorial
A humble request to set background of color of scaffold to black from now onwards. It's just too much bright while watching your videos during night time.
And thanks for good tuts! :)
- Dark theme fan!
pretty good explanation.
Awesome.
simple thanks
@Reso Coder: awesome as each piece of any tutorial from you! Is now there part 2?
well explained
Thanks
Excellent
Nice presentation....
great introduction waiting for second one
It's coming out today!
Thank you for your video. Help me in creating Shimmer loader for my application.
Good job sir! What theme are u using ?
Thanks for help and explation. Wich one are you uses theme ? Thanks.
How do you increase the speed of the rotation?
Hi Matej! Any chance for a flutter gallery app which loads images from an API? Thanks
This was a long time confusion among us. Thanks for clarifying. One question: Since our animation keeps going on for forever, does this mean everything under the scaffold along with the animating asset builds? If thats the case, how can we limit the rebuilding to only the animation portion of the build tree? Are the next part of the animation tutorials a way to accomplish this? Or is there a way to accomplish this with this approach? To be clear, we didn't have anything else in the scaffold except the animating child, but lets say we did:)
I'm glad you got it cleared up! I'm not entirely sure but on the official Flutter channel, I've heard that the widget tree is rebuilt in the most performant way possible. Since animation is really just a regular UI rebuild, Flutter will apply the same optimizations as with any other setState call.
Would like to know that, too!
@@ResoCoder @MTECHVIRAL Hello sir, i request you to create a tutorial on setting wallpapers in flutter. I'm trying to find this from past 2 weeks but no video has perfect explanation and most of them not even works....
the AnimationController object has duration as 5 seconds and since it is made parent of CurvedAnimation object, Shouldn't the animation last only 5 seconds?
Can you say me the theme name please. I ❤️ this theme but don't know it's name😭
import 'package:flutter/material.dart';
class TwoCards extends StatefulWidget {
const TwoCards({Key? key}) : super(key: key);
@override
State createState() => _TwoCardsState();
}
class _TwoCardsState extends State
with SingleTickerProviderStateMixin {
late AnimationController controller;
late Animation scaleOne;
late Animation scaleTwo;
late Animation leftRotation;
late Animation rightRotation;
@override
void initState() {
super.initState();
controller = AnimationController(
vsync: this, duration: const Duration(milliseconds: 1300));
scaleOne = Tween(begin: 0, end: 1).animate(
CurvedAnimation(parent: controller, curve: const Interval(0.0, 0.5)));
leftRotation = Tween(begin: 5, end: 0).animate(
CurvedAnimation(parent: controller, curve: const Interval(0.0, 0.5)));
scaleTwo = Tween(begin: 0, end: 1).animate(
CurvedAnimation(parent: controller, curve: const Interval(0.5, 1.0)));
rightRotation = Tween(begin: 5, end: 0).animate(
CurvedAnimation(parent: controller, curve: const Interval(0.5, 1.0)));
controller.forward();
controller.addListener(() {
setState(() {});
});
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.black,
),
body: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
CustomCard(
color: Colors.black,
rotation: leftRotation.value,
scale: scaleOne.value),
CustomCard(
color: Colors.blue.withOpacity(0.5),
rotation: rightRotation.value,
scale: scaleTwo.value),
],
),
),
);
}
}
class CustomCard extends StatelessWidget {
CustomCard(
{Key? key,
required this.color,
required this.rotation,
required this.scale})
: super(key: key);
double scale;
double rotation;
Color color;
@override
Widget build(BuildContext context) {
return Expanded(
child: Transform(
alignment: Alignment.center,
transform: Matrix4.identity()
..scale(scale)
..rotateZ(rotation),
child: Container(
margin: const EdgeInsets.all(20),
color: color,
width: 200,
height: 200,
),
),
);
}
}