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
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/DialogRouter.dart';
Future popLoadingDialog(
BuildContext context, bool canceledOnTouchOutside, String text) {
return Navigator.push(
context, DialogRouter(LoadingDialog(canceledOnTouchOutside, text)));
}
void dismissLoadingDialog(BuildContext context) {
Navigator.pop(context);
}
class LoadingDialog extends Dialog {
LoadingDialog(this.canceledOnTouchOutside, this.text) : super();
///点击背景是否能够退出
final bool canceledOnTouchOutside;
final String text;
@override
Widget build(BuildContext context) {
return Center(
child: new Material(
///背景透明
color: Colors.black54,
///保证控件居中效果
child: Stack(
children: <Widget>[
GestureDetector(
///点击事件
onTap: () {
if (canceledOnTouchOutside) {
Navigator.pop(context);
}
},
),
_dialog()
],
)),
);
}
Widget _dialog() {
return new Center(
///弹框大小
child: new Container(
width: 120.0,
height: 120.0,
child: new Container(
///弹框背景和圆角
decoration: ShapeDecoration(
color: Color(0xffffffff),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
text,
style: new TextStyle(fontSize: 16.0),
),
),
],
),
),
),
);
}
}