我需要知道在将小部件添加到列表后是否有任何可能的方法来更新小部件的属性,例如大小和颜色。请考虑以下代码。
List<Widget> tree = [];
当它被拖放到容器上时,我正在添加以下小部件。为了显示多个小部件,我正在使用堆栈..
DragTarget 和 Stack 如下...
DragTarget<String>(
builder: (a,b,c)=>Stack(
children: tree,
),
onAccept: (data){
tree.add(Positioned(
key: Key("$sx$sy"),
top: _y,
left: _x,
child: FlatButton(
onPressed: (){
},
child: CustomPaint(
size: Size(sx/2, sy/2),
painter: ShapePainter(shape: "circle", sx : sx/2, sy: sy/2),
child: Container(
width: sx,
height: sy,
),
),
),
)
);
}
从图像..我想实现这一点,每当我点击一个圆圈时,我应该能够通过手势更新它的形状和大小..
笔记
我通过创建一个相同类型和所需属性的新小部件而不是通过手势而是通过在 InputFields 中填充详细信息然后以下列方式替换它来实现类似的功能..
List<Widget> tree;
//Then replace it with..
tree.insert(0, Container());
OR
tree.insert(1, Container());
我不需要这个工作..
我需要访问我单击的项目的属性,然后使用手势更新其形状和大小。
资源
如果您需要查看我的完整代码,请使用https://github.com/AbhijeetDash/designer 随意贡献..
