Skip to content

Commit 20fe1db

Browse files
committed
add the progress indicator.
1 parent b7d1fd5 commit 20fe1db

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

lib/const/page_item_const.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,9 @@ const PAGE_ITEMS = [
142142
"img": PageImage.FLUTTER_OPEN,
143143
"click": PageName.DATA_TABLE,
144144
},
145+
{
146+
"title": PageName.PROGRESS_INDICATOR,
147+
"img": PageImage.FLUTTER_OPEN,
148+
"click": PageName.PROGRESS_INDICATOR,
149+
},
145150
];

lib/const/page_name_const.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ class PageName {
3333
static const CARD = "CARD";
3434
static const TOOLTIP = "Tooltip";
3535
static const DATA_TABLE = "DataTable";
36+
static const PROGRESS_INDICATOR = "ProgressIndicator";
3637
}

lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class FlutterOpenApp extends StatelessWidget {
4747
PageName.CARD: (context) => CardPage(),
4848
PageName.TOOLTIP: (context) => TooltipPage(),
4949
PageName.DATA_TABLE: (context) => DataTablePage(),
50+
PageName.PROGRESS_INDICATOR: (context) => ProgressIndicatorPage(),
5051
},
5152
);
5253
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
///
2+
/// Created by NieBin on 2019/5/17
3+
/// Github: https://github.com/nb312
4+
5+
///
6+
import "package:flutter/material.dart";
7+
import 'package:flutter_widgets/const/_const.dart';
8+
9+
class ProgressIndicatorPage extends StatefulWidget {
10+
@override
11+
ProgressIndicatorState createState() => ProgressIndicatorState();
12+
}
13+
14+
class ProgressIndicatorState extends State<ProgressIndicatorPage>
15+
with SingleTickerProviderStateMixin {
16+
var t = Tween(begin: BLUE, end: YELLOW);
17+
AnimationController _controller;
18+
var pro = Tween<double>(begin: 0.0, end: 1.0);
19+
var len = 0.0;
20+
21+
@override
22+
void initState() {
23+
super.initState();
24+
_controller =
25+
AnimationController(vsync: this, duration: Duration(seconds: 10));
26+
pro.animate(_controller).addListener(() => setState(() {
27+
print("len = $len");
28+
len = _controller.value;
29+
}));
30+
_controller.forward();
31+
}
32+
33+
Widget _lineIndicator() => Container(
34+
constraints: BoxConstraints.expand(width: 100, height: 10),
35+
child: LinearProgressIndicator(
36+
backgroundColor: BLUE,
37+
value: len,
38+
),
39+
);
40+
41+
Widget _circleIndicator() => Container(
42+
constraints: BoxConstraints.expand(width: 100, height: 100),
43+
child: CircularProgressIndicator(
44+
value: len,
45+
backgroundColor: YELLOW,
46+
// valueColor: t.animate(_controller),
47+
strokeWidth: 10,
48+
),
49+
);
50+
51+
@override
52+
Widget build(BuildContext context) {
53+
return Scaffold(
54+
appBar: AppBar(
55+
title: Text(PageName.PROGRESS_INDICATOR),
56+
),
57+
body: Center(
58+
child: Column(
59+
children: <Widget>[
60+
_lineIndicator(),
61+
_circleIndicator(),
62+
],
63+
),
64+
));
65+
}
66+
67+
@override
68+
void dispose() {
69+
super.dispose();
70+
_controller.dispose();
71+
}
72+
}
73+
//Key key,
74+
// double value,
75+
//Color backgroundColor,
76+
// Animation<Color> valueColor,
77+
//String semanticsLabel,
78+
// String semanticsValue,
79+
//}

lib/page/info/_info.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
export "CardPage.dart";
77
export "TooltipPage.dart";
88
export 'DataTablePage.dart';
9+
export 'ProgressIndicatorPage.dart';

0 commit comments

Comments
 (0)