-
Notifications
You must be signed in to change notification settings - Fork 3
/
dialog.dart
37 lines (31 loc) · 1.27 KB
/
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
// Copyright (c) 2023, Halil Durmus. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import 'package:windows_foundation/windows_foundation.dart';
import 'package:windows_ui/windows_ui.dart';
void main() async {
const title = 'Updates available';
const content = 'New updates have been found for this program. Would you '
'like to install the new updates?';
// Create a message dialog
final messageDialog = MessageDialog.createWithTitle(content, title);
// Initialize the MessageDialog
InitializeWithWindow.initialize(messageDialog);
// Add commands
messageDialog.commands
?..append(UICommand.create('Install updates'))
..append(UICommand.create("Don't install"));
messageDialog
// Set the command that will be invoked by default
..defaultCommandIndex = 0
// Set the command to be invoked when escape is pressed
..cancelCommandIndex = 1;
// Show the message dialog
final selectedCommand = await messageDialog.showAsync();
switch (selectedCommand?.label) {
case 'Install updates':
print('"Install updates" button is selected.');
case "Don't install":
print('"Don\'t install" button is selected.');
}
}