大佬教程收集整理的这篇文章主要介绍了Flutter进阶—质感设计之进度条,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
LinearProgressInDicator控件是质感设计中的线性进度指示器。
import 'package:Flutter/material.dart';
class ActionViewEcology extends StatelessWidget {
/* * 构建函数,传递参数 * 最大能量值 * 最大饥饿值 * 最大情绪值 * 当前能量值 * 当前饥饿值 * 当前情绪值 */
ActionViewEcology({
this.maximumEmergy,this.maximumHunger,this.maximumMood,this.currentEmergy,this.currentHunger,this.currentMood,});
int maximumEmergy;
int maximumHunger;
int maximumMood;
int currentEmergy;
int currentHunger;
int currentMood;
// 获取进度条描述文本
Align _getNameText(BuildContext context,String text) {
return new Align(
alignment: FractionalOffset.topLeft,child: new Text(
text,style: new TextStyle(
fontSize: 15.0,color: Colors.black,height: 1.5,)
)
);
}
@override
Widget build(BuildContext context) {
return new Container(
margin: const EdgeInsets.fromLTRB(17.0,0.0,17.0,10.0),child: new column(
children: <Widget> [
_getNameText(context,'能量($currentEmergy/$maximumEmergy)'),new LinearProgressInDicator(value: currentEmergy/maximumEmergy),_getNameText(context,'饥饿($currentHunger/$maximumHunger)'),new LinearProgressInDicator(value: currentHunger/maximumHunger),'心情($currentMood/$maximumMood)'),new LinearProgressInDicator(value: currentMood/maximumMood),]
)
);
}
}
在main.dart中调用上面的ActionViewEcology类,传入相关参数,效果如下:
@H_301_4@以上是大佬教程为你收集整理的Flutter进阶—质感设计之进度条全部内容,希望文章能够帮你解决Flutter进阶—质感设计之进度条所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。