mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-05-20 06:26:21 +08:00
41 lines
920 B
Dart
41 lines
920 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(MaterialApp(
|
|
home: MyHome(),
|
|
));
|
|
}
|
|
|
|
class MyHome extends StatefulWidget {
|
|
@override
|
|
MyHomeState createState() => MyHomeState();
|
|
}
|
|
|
|
class MyHomeState extends State<MyHome> {
|
|
// Generate dialog
|
|
AlertDialog dialog = AlertDialog(
|
|
content: Text(
|
|
"Hello World!",
|
|
style: TextStyle(fontSize: 30.0),
|
|
));
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Using Alert Dialog"),
|
|
),
|
|
body: Container(
|
|
child: Center(
|
|
child: RaisedButton(
|
|
child: Text("Hit to alert!"),
|
|
// On press of the button
|
|
onPressed: () {
|
|
// Show dialog
|
|
showDialog(context: context, builder: (BuildContext context) => dialog);
|
|
}),
|
|
),
|
|
));
|
|
}
|
|
}
|