mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-09-20 23:36:36 +08:00
implemented using_alert_dialog
This commit is contained in:
40
using_alert_dialog/lib/main.dart
Normal file
40
using_alert_dialog/lib/main.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new MyHome(),
|
||||
));
|
||||
}
|
||||
|
||||
class MyHome extends StatefulWidget {
|
||||
@override
|
||||
MyHomeState createState() => new MyHomeState();
|
||||
}
|
||||
|
||||
class MyHomeState extends State<MyHome> {
|
||||
// Generate dialog
|
||||
AlertDialog dialog = new AlertDialog(
|
||||
content: new Text(
|
||||
"Hello World!",
|
||||
style: new TextStyle(fontSize: 30.0),
|
||||
));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("Using Alert Dialog"),
|
||||
),
|
||||
body: new Container(
|
||||
child: new Center(
|
||||
child: new RaisedButton(
|
||||
child: new Text("Hit to alert!"),
|
||||
// On press of the button
|
||||
onPressed: () {
|
||||
// Show dialog
|
||||
showDialog(context: context, child: dialog);
|
||||
}),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user