Skip to content

Instantly share code, notes, and snippets.

@paldepind
Created February 4, 2024 12:42
Show Gist options
  • Save paldepind/79b890fd2a994d6e3f5ac210f433e7d5 to your computer and use it in GitHub Desktop.
Save paldepind/79b890fd2a994d6e3f5ac210f433e7d5 to your computer and use it in GitHub Desktop.
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