In this example, we will learn about LinearProgressIndicator Flutter Usage. Use the below example to see the LinearProgressIndicator Flutter Usage.
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 | import 'dart:async'; import 'package:flutter/material.dart'; void main() { runApp(new MaterialApp( debugShowCheckedModeBanner: false, home: new MyApp(), )); } class MyApp extends StatefulWidget { @override MyAppState createState() => new MyAppState(); } class MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text('Slider Demo'), ), body: new Container( color: Colors.blueAccent, padding: new EdgeInsets.all(32.0), child: new ProgressIndicatorDemo(), ), ); } } class ProgressIndicatorDemo extends StatefulWidget { @override _ProgressIndicatorDemoState createState() => new _ProgressIndicatorDemoState(); } class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with SingleTickerProviderStateMixin { AnimationController controller; Animation<double> animation; @override void initState() { super.initState(); controller = AnimationController( duration: const Duration(milliseconds: 2000), vsync: this); animation = Tween(begin: 0.0, end: 1.0).animate(controller) ..addListener(() { setState(() { // the state that has changed here is the animation object’s value }); }); controller.repeat(); } @override void dispose() { controller.stop(); super.dispose(); } @override Widget build(BuildContext context) { return new Center( child: new Container( child: LinearProgressIndicator( value: animation.value,), ) ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.