LinearProgressIndicator控件是質(zhì)感設(shè)計中的線性進度指示器,具體內(nèi)容如下
import 'package:flutter/material.dart';class ActionViewEcology extends StatelessWidget { /* * 構(gòu)建函數(shù),傳遞參數(shù) * 最大能量值 * 最大饑餓值 * 最大情緒值 * 當(dāng)前能量值 * 當(dāng)前饑餓值 * 當(dāng)前情緒值 */ 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中調(diào)用上面的ActionViewEcology類,傳入相關(guān)參數(shù),效果如下:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。
新聞熱點
疑難解答