Skip to content

Commit

Permalink
Initial animation with bounds -1.0 .. 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiandreplace committed Mar 11, 2018
1 parent d1f9224 commit 5d9e340
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .metadata
@@ -0,0 +1,8 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: fd6baba1373c1dde90511ca15d9cc89aa642fe3e
channel: master
2 changes: 2 additions & 0 deletions lib/main.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_animations/pages/animation_controller_output.dart';
import 'package:flutter_animations/pages/home_page.dart';
import 'package:flutter_animations/pages/using_animation_controller.dart';

void main() => runApp(new MyApp());

Expand All @@ -16,6 +17,7 @@ class MyApp extends StatelessWidget {
home: new HomePage(),
routes: <String, WidgetBuilder>{
"/animation_controller_output": (BuildContext context) => new AnimationControllerOutputPage(),
"/using_animation_controller": (BuildContext context) => new UsingAnimationControllerPage(),
}
);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/pages/home_page.dart
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_animations/pages/animation_controller_output.dart';


class HomePage extends StatelessWidget {
Expand Down Expand Up @@ -28,6 +27,13 @@ class ExamplesListWidget extends StatelessWidget {
targetRoute: "/animation_controller_output"
),
new Divider(),
new ListRow(
id: "2",
title: "Using AnimationController",
subtitle: "Examples on how to use the AnimationController",
targetRoute: "/using_animation_controller"
),
new Divider(),
],
),
);
Expand Down
66 changes: 66 additions & 0 deletions lib/pages/using_animation_controller.dart
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';


class UsingAnimationControllerPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Using animation controller"),
),
body: new UsingAnimationControllerBody(),
);
}
}


class UsingAnimationControllerBody extends StatefulWidget {
@override
_UsingAnimationControllerBodyState createState() =>
new _UsingAnimationControllerBodyState();
}

class _UsingAnimationControllerBodyState
extends State<UsingAnimationControllerBody>
with SingleTickerProviderStateMixin {

AnimationController _controller;

@override
void initState() {
super.initState();


_controller = new AnimationController(
lowerBound: -1.0,
upperBound: 1.0,
duration: new Duration(seconds: 2),
vsync: this
)
..addListener(() {
this.setState(() {});
});


_controller.forward(from: -1.0);
}

@override
Widget build(BuildContext context) {

return new Stack(
fit: StackFit.expand,
children: <Widget>[
new FractionallySizedBox(
heightFactor: 0.2,
widthFactor: 0.2,
alignment: new Alignment(_controller.value, 0.0),
child: new Icon(
Icons.flight,
size: 80.0,
)
),
],
);
}
}

0 comments on commit 5d9e340

Please sign in to comment.