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
| import 'package:flutter/material.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Adaptive Dialog Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Adaptive Dialog Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: Text('显示确认对话框'),
onPressed: () async {
final result = await showOkCancelAlertDialog(
context: context,
title: '确认',
message: '你确定要执行此操作吗?',
);
print(result);
},
),
SizedBox(height: 20),
ElevatedButton(
child: Text('显示输入对话框'),
onPressed: () async {
final result = await showTextInputDialog(
context: context,
title: '登录',
textFields: [
DialogTextField(hintText: '用户名'),
DialogTextField(
hintText: '密码',
obscureText: true,
),
],
);
print(result);
},
),
],
),
),
);
}
}
|