flutter - !_needsLayout 不是真的颤振 lite_rolling_switcher
问题描述
我正在尝试在 listview 中实现 LiteRollingSwithcer 并且由于某种原因得到了异常:
Error: Assertion failed:
..\…\painting\text_painter.dart:881
!_needsLayout
is not true
每次我将鼠标悬停在 LiteRollingSwithcer 小部件上时都会发生此错误。感谢您的帮助:) 这是我的代码:
return Container(
child: ReorderableListView(
children: <Widget>[
for (final item in widget.pickList)
Card(
color: bgColor,
key: ValueKey(item),
elevation: 2,
child: Padding(
padding: const EdgeInsets.fromLTRB(
0, defaultPadding / 2, 0, defaultPadding / 2),
child: ListTile(
title: Text(item),
leading: Container(
padding: const EdgeInsets.all(5),
child: LiteRollingSwitch(
value: true,
textOn: 'Yes',
textOff: 'No',
colorOn: Colors.cyan,
colorOff: Colors.red[400],
iconOn: Icons.check,
iconOff: Icons.power_settings_new,
animationDuration: Duration(milliseconds: 800),
onChanged: (bool state) {
print('turned ${(state) ? 'yes' : 'no'}');
},
),
),
),
),
),
],
onReorder: reorderData,
),
);
解决方案
推荐阅读
- javascript - 如何通过 POST 传递 Javascript 变量以在 Flask 中使用?
- node.js - 从 NodeJS 插入 1084 后 MongoDB 连接错误
- python - 如何对具有复杂字符串的字母数字列表进行排序
- python - 优化查询和整理结果
- python - Python XML:'TypeError:SubElement() 参数 1 必须是 xml.etree.ElementTree.Element,而不是 Element'
- python - Tobii-Eyetracker with python,无法打印眼动数据
- python - 把北美分成几块
- javascript - 使用 PHP 和 JS 将文件保存到服务器?
- c# - 在后面的代码中执行授权检查
- reactjs - 如何从父组件刷新子组件