-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathday058_alert_dialog.dart
109 lines (106 loc) · 3.81 KB
/
day058_alert_dialog.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Day58AlertDialog extends StatefulWidget {
Day58AlertDialog({Key key}) : super(key: key);
@override
_Day58AlertDialogState createState() => _Day58AlertDialogState();
}
class _Day58AlertDialogState extends State<Day58AlertDialog> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () {
/**
* ? What is AlertDialog....
* ! AlertDialog is the Widget where we can display the pop up dialog for the user....
*/
showDialog(
// ! show dialog is the function which is used to trigger the dialog....
context: context,
builder: (context) => AlertDialog(
// ! AlertDialog is the normal android....
title: Text(
"This is Android AlertDialog"), // ! had title display heading....
content: Text(
"Click OK/Back"), // ! had content display message.....
actions: <Widget>[
// ! here we had the action button....
FlatButton(
onPressed: () {
Navigator.pop(
context); // ! to pop out the Dialog....
},
child: Text("OK")),
FlatButton(
onPressed: () {
Navigator.pop(context);
},
child: Text("Back"))
],
),
);
},
child: Text("Android AlertDialog"),
),
SizedBox(
height: 50,
),
RaisedButton(
onPressed: () {
showDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
// ! CupertinoAlertDialog is the iPhone android....
title: Text("This is iPhone AlertDialog"),
content: Text("Click Ok/Back"),
actions: <Widget>[
CupertinoDialogAction(
// ! CupertinoDialogAction is for the action buttons....
child: Text("Ok"),
onPressed: () {
Navigator.pop(context); // ! to pop out the Dialog....
},
),
CupertinoDialogAction(
child: Text("Back"),
onPressed: () {
Navigator.pop(context);
},
),
],
),
);
},
child: Text("iPhone AlertDialog"),
),
],
),
),
appBar: AppBar(
title: Text("AlertDialog"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.help),
onPressed: () async {
const url =
'https://github.com/sanjaysanju618/100-Days-Of-Flutter-Widgets/' +
'blob/master/hundred_days_of_flutter_widget/' +
'lib/day058_alert_dialog.dart';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
)
],
),
);
}
}