-
Notifications
You must be signed in to change notification settings - Fork 1
/
animate3.dart
39 lines (32 loc) · 1.33 KB
/
animate3.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Demonstrate a repeating animation
import 'package:flutter/animation.dart';
import 'package:flutter/material.dart';
const kLogoUrl =
"https://raw.githubusercontent.com/dart-lang/logos/master/logos_and_wordmarks/dart-logo.png";
class LogoApp extends AnimatedComponent {
LogoApp({Key key, Animation<double> animation})
: super(key: key, animation: animation);
Widget build(BuildContext context) {
return new Center(
child: new Container(
margin: new EdgeInsets.symmetric(vertical: 10.0),
height: animation.value,
width: animation.value,
child: new Image.network(kLogoUrl)));
}
}
void main() {
final AnimationController controller =
new AnimationController(duration: const Duration(milliseconds: 2000));
final Animation<double> animation =
new Tween(begin: 0.0, end: 300.0).animate(controller)..addStatusListener((state) => print("$state") );
animation.addStatusListener((status) {
if (status == AnimationStatus.completed) controller.reverse();
else if (status == AnimationStatus.dismissed) controller.forward();
});
runApp(new LogoApp(animation: animation));
controller.forward();
}