Animation Tween

 import "package:flutter/material.dart";


void main() {
runApp(const AmanDemo(),);
}
class AmanDemo extends StatelessWidget {
const AmanDemo({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Tween Animation in Flutter",
theme: ThemeData(
primarySwatch: Colors.brown,
),
home: const TweenDemo(),
);
}
}
class TweenDemo extends StatefulWidget {
const TweenDemo({super.key});

@override
State<TweenDemo> createState() {
return TweenState();
}
}
class TweenState extends State<TweenDemo> with SingleTickerProviderStateMixin {
late Animation animation;
late Animation colorAnimation;
late AnimationController animationController;

@override
void initState() {
super.initState();

animationController = AnimationController(vsync: this, duration: const Duration(seconds: 2,),);
animation = Tween(begin: 50.0, end: 300.0).animate(animationController);
colorAnimation = ColorTween(begin: Colors.blue, end: Colors.orange).animate(animationController);

animationController.addListener(() {
print(animation.value);
setState(() {},);
},);

animationController.forward();

}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Tween Animation"),
),
body: Center(
child: Container(
width: animation.value,
height: animation.value,
color: colorAnimation.value,
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter