Skip to content

Instantly share code, notes, and snippets.

@Shubham-Narkhede
Created December 15, 2019 17:51
Show Gist options
  • Save Shubham-Narkhede/6858458ce64f880110511c764c5cebaa to your computer and use it in GitHub Desktop.
Save Shubham-Narkhede/6858458ce64f880110511c764c5cebaa to your computer and use it in GitHub Desktop.
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