-
Notifications
You must be signed in to change notification settings - Fork 0
/
linear_progress_indicator.dart
90 lines (82 loc) · 2.71 KB
/
linear_progress_indicator.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
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
88
89
90
import 'package:flutter/material.dart';
import 'package:flutter_demo/tabbar/mine/component/content_text.dart';
import 'package:flutter_demo/tabbar/mine/component/title_text.dart';
class LinearProgressIndicatorPage extends StatefulWidget {
@override
_LinearProgressIndicatorPageState createState() => _LinearProgressIndicatorPageState();
}
class _LinearProgressIndicatorPageState extends State<LinearProgressIndicatorPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("LinearProgressIndicator"),
),
body: ListView(
children: <Widget>[
TitleTextPage("简介:"),
ContentTextPage(["进度条。"]),
TitleTextPage("属性:"),
ContentTextPage([
"value:进度(取值范围0-1),当value等于null时为不确定进度,会有一个取得进度的动画效果。",
"valueColor:进度颜色,可以通过AlwaysStoppedAnimation<Color>()设置,当value等于null可""以通过Animation<Color>实现一个颜色渐变的进度条。",
"backgroundColor: 背景颜色(未读取进度部分的颜色)。"
]),
TitleTextPage("例子:"),
LinearProgressIndicatorDemo()
],
),
);
}
}
class LinearProgressIndicatorDemo extends StatefulWidget {
@override
_LinearProgressIndicatorDemoState createState() => _LinearProgressIndicatorDemoState();
}
class _LinearProgressIndicatorDemoState extends State<LinearProgressIndicatorDemo> with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<Color> _animation;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 1),
vsync: this,
)..repeat();
_animation = new ColorTween(
begin: Colors.red, end: Colors.amber
).animate(_controller);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
LinearProgressIndicator(
valueColor: _animation,
),
SizedBox(height: 30,),
LinearProgressIndicator(
value: 0.5,
backgroundColor: Colors.black12,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
),
SizedBox(height: 30,),
Container(
height: 3,
child: LinearProgressIndicator(
value: 0.3,
backgroundColor: Colors.black12,
valueColor: AlwaysStoppedAnimation<Color>(Colors.green),
),
)
],
)
);
}
}