LinearProgressIndicator颤动用法

LinearProgressIndicator颤动用法,第1张

LinearProgressIndicator颤动用法

您没有使用动画对象

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,),        )    );  }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4974935.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存