flutter的进度条组件代码片
Easul Lv4

普通进度条

折叠代码块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
// 线性进度条,会一直动
Padding(
padding: EdgeInsets.only(top: 0.0),
child: LinearProgressIndicator(
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation(Colors.blue),
),
),

// 线性进度条,进度条显示50%
Padding(
padding: EdgeInsets.only(top: 20.0),
child: LinearProgressIndicator(
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation(Colors.blue),
value: .5,
),
),
// 圆形指示器,会一直动
Padding(
padding: EdgeInsets.only(top: 20.0),
child: CircularProgressIndicator(
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation(Colors.orange),
),
),
// 圆形指示器,静止状态
Padding(
padding: EdgeInsets.only(top: 20.0),
child: CircularProgressIndicator(
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation(Colors.blue),
value: .5,
),
),
// 线性进度条,指定高度
Padding(
padding: EdgeInsets.only(top: 20.0),
child: SizedBox(
height: 3,
child: LinearProgressIndicator(
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation(Colors.blue),
value: .5,
),
),
),
// 圆形指示器,椭圆形
Padding(
padding: EdgeInsets.only(top: 20.0),
child: SizedBox(
height: 20,
width: 50,
child: CircularProgressIndicator(
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation(Colors.blue),
),
),
),

整页覆盖加载组件

折叠代码块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
// 使用的时候可以放到 Stack 的 children 的最后,然后通过全局变量进行页面显示
// 如 _isLoading ? _showLoadingDialog() : Column()
Widget _showLoadingDialog({Color color = Colors.black}) {
return Stack(children: [
Opacity(
opacity: 0.8,
child: Container(
color: color,
width: window.physicalSize.width,
height: window.physicalSize.height,
),
),
AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
CircularProgressIndicator(),
Padding(
padding: EdgeInsets.only(top: 26.0),
child: Text("正在加载,请稍后..."),
)
],
),
),
]);
}
 评论
来发评论吧~
Powered By Valine
v1.5.2