Skip to content

Commit e4508f4

Browse files
committed
Add showDialog when flavour is not selected
1 parent 27b4220 commit e4508f4

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

lib/pages/input_page.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ class _InputPageState extends State<InputPage> {
216216
style: TextStyle(color: Colors.white, fontSize: 20),
217217
),
218218
onPressed: () {
219-
if (flavourSelected != null) {
219+
if (flavourSelected == null) {
220+
buildShowDialog(context);
221+
} else {
220222
double price =
221223
flavourSelected == Flavours.Margarita ? 11.5 : 13.5;
222224

@@ -242,4 +244,20 @@ class _InputPageState extends State<InputPage> {
242244
],
243245
));
244246
}
247+
248+
Future<String> buildShowDialog(BuildContext context) {
249+
return showDialog<String>(
250+
context: context,
251+
builder: (BuildContext context) => AlertDialog(
252+
title: const Text('No flavour selected'),
253+
content: const Text('Please select a pizza flavour'),
254+
actions: <Widget>[
255+
TextButton(
256+
onPressed: () => Navigator.pop(context, 'OK'),
257+
child: const Text('OK'),
258+
),
259+
],
260+
),
261+
);
262+
}
245263
}

0 commit comments

Comments
 (0)