forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalertdialog.dart
61 lines (57 loc) · 1.64 KB
/
alertdialog.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyAlertDialog extends StatefulWidget {
const MyAlertDialog({Key? key}) : super(key: key);
@override
State<MyAlertDialog> createState() => _MyAlertDialogState();
}
class _MyAlertDialogState extends State<MyAlertDialog> {
void _showDialog() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Title'),
content: const Text('Content, more information'),
actions: [
MaterialButton(
color: Colors.deepPurple[200],
onPressed: () {
// do something
print('Ok button pressed');
},
child: const Text('Ok'),
),
MaterialButton(
color: Colors.deepPurple[200],
onPressed: () {
// do something
Navigator.pop(context);
},
child: const Text('Cancel'),
)
],
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.deepPurple[100],
appBar: AppBar(title: const Text('Alert Dialog')),
body: Center(
child: MaterialButton(
color: Colors.deepPurple[300],
onPressed: _showDialog,
child: const Padding(
padding: EdgeInsets.all(10.0),
child: Text(
'SHOW DIALOG',
style: TextStyle(fontSize: 24),
),
),
),
),
);
}
}