|
| 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 | +//} |
0 commit comments