Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flutter alert dialog
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