Flutter 重绘边界重绘规则

问题描述

每当 _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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...