Last active
May 21, 2019 03:39
-
-
Save qwert2603/f8e77d2efc23cde488efb1a449637070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:circular_reveal_animation/circular_reveal_animation.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'CRA Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> | |
with SingleTickerProviderStateMixin { | |
AnimationController animationController; | |
Animation<double> animation; | |
@override | |
void initState() { | |
super.initState(); | |
animationController = AnimationController( | |
vsync: this, | |
duration: Duration(milliseconds: 1000), | |
); | |
animation = CurvedAnimation( | |
parent: animationController, | |
curve: Curves.easeIn, | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("CRA Demo"), | |
), | |
body: Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: CircularRevealAnimation( | |
minRadius: 12, | |
maxRadius: 200, | |
center: Offset(0, 300), | |
child: Container(color: Colors.red), | |
animation: animation, | |
), | |
), | |
floatingActionButton: FloatingActionButton(onPressed: () { | |
if (animationController.status == AnimationStatus.forward || | |
animationController.status == AnimationStatus.completed) { | |
animationController.reverse(); | |
} else { | |
animationController.forward(); | |
} | |
}), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment