I want to use SizeTransition widget for just an image not for page. It will be my loading page and while loading the application app symbol will be displayed with a size transition.
https://docs.flutter.io/flutter/widgets/SizeTransition-class.html
I want my logo with this effect in the link. However there is not enough source for me to learn about that widget. Can you please give me an example? I tried something like this but it;s not working.
class _AnimTestState extends State<AnimTest>
with SingleTickerProviderStateMixin {
AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(vsync: this);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SizeTransition(
child: Image.asset('assets/images/appLogo.png'),
sizeFactor: CurvedAnimation(
curve: Curves.fastOutSlowIn,
parent: controller,
),
),
);
}
}
class _AnimTestState extends State<HomePage> with SingleTickerProviderStateMixin {
AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 400),
)..repeat(reverse: true); // automatically animation will be started
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SizeTransition(
child: Image.asset('assets/images/appLogo.png'),
sizeFactor: CurvedAnimation(
curve: Curves.fastOutSlowIn,
parent: controller,
),
),
);
}
}
You can also use _controller.forward()
or _controller.reverse()
in a button press if you don't want it to run automatically like I did.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With