Skip to content

Instantly share code, notes, and snippets.

@rutvik110
Created November 4, 2021 09:25
Show Gist options
  • Save rutvik110/a4e7f8077d1ed1c419d2a26bab20b92e to your computer and use it in GitHub Desktop.
Save rutvik110/a4e7f8077d1ed1c419d2a26bab20b92e to your computer and use it in GitHub Desktop.
My Explicit Animation
import 'package:flutter/material.dart';
class MyExplicitAnimation extends StatefulWidget {
const MyExplicitAnimation({Key? key}) : super(key: key);
@override
_MyExplicitAnimationState createState() => _MyExplicitAnimationState();
}
class _MyExplicitAnimationState extends State<MyExplicitAnimation>
with SingleTickerProviderStateMixin {
late AnimationController _animationController;
@override
void initState() {
// TODO: implement initState
super.initState();
_animationController =
AnimationController(vsync: this, duration: const Duration(seconds: 3));
_animationController.forward();
}
@override
void dispose() {
// TODO: implement dispose
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
child!,
const SizedBox(
height: 20,
),
Transform.scale(
scale: _animationController.value,
child: Container(
height: 100,
width: 100,
color: Colors.blue,
),
),
],
));
},
child: const Text(
"This child is not Related To Animation.\nSo won't rebuild when animation value changes.")),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment