华域联盟 Andriod Flutter质感设计之进度条

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),
     _getNameText(context, '心情($currentMood/$maximumMood)'),
     new LinearProgressIndicator(value: currentMood/maximumMood),
    ]
   )
  );
 }
}

在main.dart中调用上面的ActionViewEcology类,传入相关参数,效果如下:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持华域联盟。

本文由 华域联盟 原创撰写:华域联盟 » Flutter质感设计之进度条

转载请保留出处和原文链接:https://www.cnhackhy.com/105799.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

Flutter质感设计之列表项

Flutter质感设计之表单输入

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们