flutter - 从外部更新 RepaintBoundary 内部
问题描述
如何从外部更新 RepaintBoundary,是否可能?我正在开发某种绘图应用程序,如果用户点击按钮,我会得到容器的屏幕截图,如果用户点击删除按钮,绘画正在清除,但在我的情况下,点列表正在清除,但容器(绘图本身)不清除。
SingleChildScrollView(//physics: NeverScrollableScrollPhysics(),
child: Column(
children: <Widget>[
RepaintBoundary(
key: _signKey,
child: new Container(
child: GestureDetector(
onPanUpdate: (DragUpdateDetails details) {
setState(() {
RenderBox object = context.findRenderObject();
Offset _localPosition =
object.globalToLocal(details.globalPosition);
points = new List.from(points)
..add(_localPosition);
});
},
onPanEnd: (DragEndDetails details) => points.add(null),
child: new CustomPaint(
painter: new DrawPainter(points: points),
size: Size.infinite,
),
),
),
),
Row(
children: <Widget>[
FlatButton(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
color: Colors.redAccent,
textColor: Colors.black,
onPressed: (){
setState(() {
points.clear();
});
},
child: Text('Sil'),
),
],
),
],
),
);
解决方案
推荐阅读
- typescript - 类型 'never[]' 不能分配给类型 '...'
- javascript - INSERT MySQL 语句:当前值和选定值 INTO VALUES 来自同一个表
- javascript - Div 样式在设置状态后更改,但在不应该时恢复
- json - 如何从 JSON 输出中获取选定的值
- java - 如何在android应用程序中将部分字节数组数据转换为浮点数据类型
- typescript - 扩展字符串文字类型时出现打字稿错误
- javascript - 我对编程还是很陌生,想从头开始编写我的第一段代码。有人可以告诉我为什么这不起作用吗?
- python - AttributeError:“HTTPClient”对象没有属性“send_files”
- javascript - 有没有办法将 ReactJS 中的多项式方程归零,使其 y 截距通过 0,这意味着图形坐标 [x= 0, y = 0]?
- c++ - C++ 天蓝色存储库,stream_buf can_read 返回 false