progress.dart
2.03 KB
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
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
class Progress extends StatelessWidget {
final double value;
final double size;
Progress(this.value, {this.size = 100.0});
Widget get progress {
return Container(
width: ScreenUtil().setWidth(30),
height: ScreenUtil().setWidth(30),
padding: EdgeInsets.all(10),
// color: Colors.red,
child: CircularProgressIndicator(
value: value,
// strokeWidth: 14,
backgroundColor: Colors.grey[200],
),
);
}
Widget get progressText {
final integer = (value * 100).toInt(); //当前上传进度
final decimal = (((value * 100) - integer) * 100).toInt(); //剩余进度
final unit = '%';
return DefaultTextStyle(
style: TextStyle(
color: Colors.black87,
// fontWeight: FontWeight.bold,
),
child:
// Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Text(
// integer.toString(),
// style: TextStyle(fontSize: ScreenUtil().setSp(13)),
// ),
// Column(
// children: [
Container(
width: ScreenUtil().setWidth(size * 2),
height: ScreenUtil().setWidth(size * 2),
color: Color.fromRGBO(0, 0, 0, 0.5),
child: Center(
child: Text('${integer}${unit}',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_fefefe)),
))
// Text('.$decimal',
// style: TextStyle(fontSize: ScreenUtil().setSp(13))),
// ],
// )
// ],
);
}
@override
Widget build(BuildContext context) {
// return Stack(
// alignment: AlignmentDirectional.center,
// children: [progress, progressText],
// );
return progressText;
}
}