flutter - Flutter 中的自定义仪表设计
问题描述
为此,我使用了 LinearGauge。但是在 Gauge 中有 CellData,它不允许我添加 Widget 或能够更改该 CellData 的形状。请分享我如何设计这个。任何参考都非常有帮助。
解决方案
尝试这个:
Widget _guage(int index) {
List<Widget> _items = [];
List<String> _status = ['V Bad', 'Bad', 'OK', 'Good', 'V Good'];
for (int i = 0; i < _status.length; i++) {
_items.add(
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 50,
child: i == index ? Icon(Icons.pin) : SizedBox(),
),
Container(
decoration: BoxDecoration(
color:
Colors.yellow.withOpacity(1 / (_status.length - i + 1)),
borderRadius: BorderRadius.circular(5),
),
height: 10 + (i.toDouble()*2),
),
Text(_status[i]),
],
),
),
);
}
return Row(
children: _items,
);
}
推荐阅读
- javascript - 读取单选按钮的值时,值未定义
- node.js - 如何使用 ask-sdk-v1adapter 将 sdk1 lambda 代码迁移到 sdk2
- c++ - 在发布版本中划分两个双打的错误结果
- jquery - 使用 DataTable 服务器端脚本在第二次单击按钮时调用 ajax 失败
- php - Symfony UniqueEntity 在更新现有实体时显示错误
- angular - 用于打印嵌套值的键值管道
- ruby-on-rails - ActionView::Template::Error - 没有路由匹配 button_to \ link_to 调用控制器动作中的动作
- c# - 一些带有条件的循环。具体问题
- apache-kafka - 是否可以从 nifi 接收数据并将该数据添加到从 kafka 接收的数据中?
- .net-core - 如何将 .net core dll 添加到现有的 .net 框架项目中?