Created
December 15, 2019 17:51
-
-
Save Shubham-Narkhede/6858458ce64f880110511c764c5cebaa to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp(title: 'Flutter Animated Popup', theme: ThemeData(), home: _myApp()); | |
} | |
} | |
class _myApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: RaisedButton.icon( | |
onPressed: () { | |
showDialog( | |
context: context, | |
builder: (_) => PopUpBox(), | |
); | |
}, | |
icon: Icon(Icons.message), | |
label: Text("PopUp!")), | |
), | |
); | |
} | |
} | |
class PopUpBox extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() => PopUpBoxState(); | |
} | |
class PopUpBoxState extends State<PopUpBox> | |
with SingleTickerProviderStateMixin { | |
AnimationController controller; | |
Animation<double> scaleAnimation; | |
@override | |
void initState() { | |
super.initState(); | |
controller = | |
AnimationController(vsync: this, duration: Duration(milliseconds: 450)); | |
scaleAnimation = | |
CurvedAnimation(parent: controller, curve: Curves.elasticInOut); | |
controller.addListener(() { | |
setState(() {}); | |
}); | |
controller.forward(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: Material( | |
color: Colors.transparent, | |
child: ScaleTransition( | |
scale: scaleAnimation, | |
child: Container( | |
decoration: ShapeDecoration( | |
color: Colors.white, | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(15.0))), | |
child: Padding( | |
padding: const EdgeInsets.all(50.0), | |
child: Text("Hello..!!"), | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment