-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfirmation_acknowledgement.dart
115 lines (109 loc) · 3.43 KB
/
confirmation_acknowledgement.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
110
111
112
113
114
115
import 'package:flutter/material.dart';
class ConfirmationAcknowledgement extends StatefulWidget {
static const routeName = '/confirm-acknowledgement';
@override
_ConfirmationAcknowledgementState createState() =>
_ConfirmationAcknowledgementState();
}
class _ConfirmationAcknowledgementState
extends State<ConfirmationAcknowledgement> {
_buildSnackbar(String content) {
_scaffoldKey.currentState.showSnackBar(SnackBar(
action: SnackBarAction(
label: 'close',
textColor: Colors.redAccent,
onPressed: () {
_scaffoldKey.currentState.hideCurrentSnackBar();
}),
content: Text(content),
duration: Duration(seconds: 5),
));
}
_buildBottomSheet(String content) {
_scaffoldKey.currentState.showBottomSheet(
(content) => Container(
height: 200,
padding: EdgeInsets.all(20),
color: Colors.grey[900],
child: Column(
children: <Widget>[
Text(
'This is a Bottom Sheet',
style: TextStyle(color: Colors.white, fontSize: 25),
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
textColor: Colors.blue,
onPressed: () => Navigator.pop(context),
child: Text('Ok')),
FlatButton(
textColor: Colors.red,
onPressed: () => Navigator.pop(context),
child: Text('Cancel')),
],
),
SizedBox(height: 20),
Text('you can also provide additional info here',
style: TextStyle(color: Colors.white))
],
),
),
);
}
_buildDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Confirmation'),
content: Text('You want to perform this action?'),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.pop(context), child: Text('Yes')),
FlatButton(
textColor: Colors.red,
onPressed: () => Navigator.pop(context),
child: Text('Cancel')),
],
),
);
}
final _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text(
'Confirmation &\nAcknowledgement',
textAlign: TextAlign.center,
),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlatButton(
color: Colors.blue,
textColor: Colors.white,
onPressed: () => _buildSnackbar('This is a Snackbar'),
child: Text('SnackBar')),
FlatButton(
color: Colors.blue,
textColor: Colors.white,
onPressed: () => _buildDialog(context),
child: Text('Alert Dialog')),
FlatButton(
color: Colors.blue,
textColor: Colors.white,
onPressed: () => _buildBottomSheet('This is a Bottom Sheet'),
child: Text('Bottom Sheet')),
],
),
),
);
}
}