Skip to content

Instantly share code, notes, and snippets.

View felixblaschke's full-sized avatar

Felix Blaschke felixblaschke

  • Frankfurt am Main, Germany
View GitHub Profile
@felixblaschke
felixblaschke / saw8.dart
Created April 25, 2020 07:39
saw8.dart
return MirrorAnimation<double>( // <-- changed to "MirrorAnimation"
duration: 800.milliseconds,
curve: Curves.easeInOut,
tween: 0.0.tweenTo(200.0),
builder: (context, child, value) {
return Container(width: value, height: value, color: Colors.green);
},
);
@felixblaschke
felixblaschke / saw7.dart
Created April 25, 2020 07:35
saw7.dart
return LoopAnimation<double>( // <-- changed to "LoopAnimation"
duration: 800.milliseconds,
curve: Curves.easeInOut,
tween: 0.0.tweenTo(200.0),
builder: (context, child, value) {
return Container(width: value, height: value, color: Colors.green);
},
);
@felixblaschke
felixblaschke / saw6.dart
Created April 25, 2020 07:32
saw6.dart
return PlayAnimation<double>( // <-- set animatino type
duration: 800.milliseconds,
curve: Curves.easeInOut,
tween: 0.0.tweenTo(200.0), // <-- double tween
builder: (context, child, value) {
return Container( // <-- return a Container
width: value, // <-- use animated value for width
height: value, // <-- use animated value for height
color: Colors.green,
);
@felixblaschke
felixblaschke / saw5.dart
Created April 25, 2020 07:28
saw5.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PlayAnimation<int>(
duration: 5.seconds, // <-- set duration
curve: Curves.easeIn, // <-- apply non-linear curve
tween: 0.tweenTo(64736),
builder: (context, child, value) {
return Text("$value likes", style: TextStyle(fontSize: 30));
},
@felixblaschke
felixblaschke / saw4.dart
Last active April 25, 2020 07:29
saw4.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PlayAnimation<int>(
tween: 0.tweenTo(64736), // <-- set tween
builder: (context, child, value) {
return Text("$value likes", style: TextStyle(fontSize: 30));
},
);
}
@felixblaschke
felixblaschke / saw3.dart
Created April 25, 2020 07:11
saw3.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PlayAnimation<int>( // <-- animate integers
builder: (context, child, value) {
return Text(
"$value likes", // <-- use animated value
style: TextStyle(fontSize: 30),
);
},
@felixblaschke
felixblaschke / saw2.dart
Last active April 25, 2020 07:15
saw2.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PlayAnimation(
builder: (context, child, value) {
return Text("64736 likes", style: TextStyle(fontSize: 30),);
},
);
}
}
@felixblaschke
felixblaschke / saw1.dart
Last active April 25, 2020 07:15
saw1.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text("64736 likes", style: TextStyle(fontSize: 30),);
}
}
@felixblaschke
felixblaschke / sa2-4.dart
Created April 22, 2020 20:15
sa2-4.dart
/* Supercharged supports your animations */
// create numeric tweens
100.0.tweenTo(200.0);
// create color tweens
Colors.red.tweenTo(Colors.yellow);
// create durations
600.milliseconds;
@felixblaschke
felixblaschke / sa2-3.dart
Created April 22, 2020 20:00
sa2-3.dart
class _MyAnimatedWidgetState extends State<MyAnimatedWidget>
with AnimationMixin { // <-- add AnimationMixin to state class
Animation<double> size; // <-- declare animation variable
@override
void initState() {
// the mixin provides you with a ready to use AnimationController as "controller" variable
size = 0.0.tweenTo(200.0).animatedBy(controller); // <-- connect tween and controller and apply to animation variable
controller.play(); // <-- start the animation playback