首页 > 解决方案 > !_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,
  ),
);

标签: flutterdart

解决方案


推荐阅读