问题描述
每当 _lastIndex
方法中的变量 setState()
发生变化时,我都想重新绘制我的 RepaintBoundary 小部件的子级。基本上,我希望 RepaintBoundary 的行为与适用于任何普通容器的行为相同 - 但由于不相关的原因,我需要一个 RepaintBoundary 而不是容器。我玩了一会儿,发现当第一个示例中的 MyPainter
更改时,子 (_lastIndex
) 会重新渲染,但在第二个示例中没有。是什么背后的规则让这两个例子的行为如此不同?
1.例子
RepaintBoundary(
key: globalKey,child: Container(
child: Container(
child: new CustomPaint(
child: Text(_lastIndex.toString()),// MyPainter is re-rendered because of this line
painter: new MyPainter(index: _lastIndex),// while this line doesn't have any effect on re-rendering
isComplex: true,willChange: false,),)
)
),
2.例子
RepaintBoundary(
key: globalKey,child: Container(
child: Container(
child: new CustomPaint(
painter: new MyPainter(index: _lastIndex),isComplex: true,
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)