Skip to content

Instantly share code, notes, and snippets.

@liyuqian
Last active December 5, 2019 01:15
Show Gist options
  • Save liyuqian/ebcb2e7a31f3a83959bbaac39f9490bd to your computer and use it in GitHub Desktop.
Save liyuqian/ebcb2e7a31f3a83959bbaac39f9490bd to your computer and use it in GitHub Desktop.
i41469.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
AnimationController animationController;
Animation<double> animation;
@override
void initState() {
super.initState();
animationController = AnimationController(
duration: new Duration(milliseconds: 250), vsync: this);
animation = Tween<double>(begin: 15, end: 75).animate(animationController)
..addListener(() {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(children: <Widget>[
Positioned(
bottom: 15,
right: 15,
child: Transform.scale(
scale: animation.value - 1,
child: FloatingActionButton(
heroTag: null,
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(10.0)),
elevation: 10.0,
onPressed: () {
animationController.forward();
},
child: Icon(Icons.add, color: Colors.white),
backgroundColor: Colors.white,
),
),
),
]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment