Created
January 19, 2020 06:39
-
-
Save vijayinyoutube/6bdbc3816a62366cf5a18738d80e7828 to your computer and use it in GitHub Desktop.
Flutter alert dialog
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:medium/test.dart'; | |
void main() { | |
runApp(MaterialApp(home: MyApp(), debugShowCheckedModeBanner: false)); | |
} | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
@override | |
@override | |
Widget build(BuildContext context) { | |
var raisedButton = FloatingActionButton.extended( | |
backgroundColor: Colors.pink, | |
icon: Icon( | |
Icons.assignment_late, | |
color: Colors.white, | |
size: 30, | |
), | |
label: Text('Show Dialog'), | |
onPressed: () { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(20.0)), | |
title: new Text("Alert ! ",style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold),), | |
content: Text("Click to continue..."), | |
actions: <Widget>[ | |
new FlatButton( | |
child: Icon( | |
Icons.check, | |
color: Colors.green, | |
size: 40, | |
), | |
onPressed: () { | |
Navigator.of(context).pop(); | |
}, | |
), | |
], | |
); | |
}, | |
); | |
}); | |
return Scaffold( | |
body: Container( | |
color: Colors.white, | |
child: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text( | |
"Dialog box in Flutter", | |
style: TextStyle( | |
fontSize: 30, | |
fontWeight: FontWeight.bold, | |
color: Colors.indigo), | |
), | |
SizedBox( | |
height: 30, | |
), | |
Container(child: raisedButton), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment