Created
February 4, 2024 12:42
-
-
Save paldepind/79b890fd2a994d6e3f5ac210f433e7d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(const LogoApp()); | |
double? first = null; | |
class AnimatedLogo extends AnimatedWidget { | |
const AnimatedLogo({super.key, required Animation<double> animation}) | |
: super(listenable: animation); | |
@override | |
Widget build(BuildContext context) { | |
final animation = listenable as Animation<double>; | |
if (first == null) { | |
// Log the first value | |
first = animation.value; | |
print(first); | |
} | |
return Center( | |
child: Container( | |
margin: const EdgeInsets.symmetric(vertical: 10), | |
height: animation.value + 100, | |
width: animation.value + 100, | |
child: const FlutterLogo(), | |
), | |
); | |
} | |
} | |
class LogoApp extends StatefulWidget { | |
const LogoApp({super.key}); | |
@override | |
State<LogoApp> createState() => _LogoAppState(); | |
} | |
class _LogoAppState extends State<LogoApp> with SingleTickerProviderStateMixin { | |
late Animation<double> animation; | |
late AnimationController controller; | |
@override | |
void initState() { | |
super.initState(); | |
controller = AnimationController( | |
duration: const Duration(seconds: 2), | |
vsync: this, | |
lowerBound: -100, | |
upperBound: 200); | |
// Swap the two lines above with the two below to see the other issue | |
// lowerBound: 100, | |
// upperBound: 300); | |
controller.repeat(); | |
} | |
@override | |
Widget build(BuildContext context) => AnimatedLogo(animation: controller); | |
@override | |
void dispose() { | |
controller.dispose(); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment