如何在Flutter中重叠两个小部件?

时间:2019-05-21 05:34:18

标签: image flutter overlap

预期输出:

This is a combination of a circle avatar with the color and and image on top of it

这是圆形化身的组合,上面有颜色和图像。

当前输出:

enter image description here

代码:

 leading: CircleAvatar(backgroundColor: contentWithIcon[value]['color']),

我如何彼此重叠?

图像路径:

assets/img/forex.png 

1 个答案:

答案 0 :(得分:5)

您不需要重叠它们或使用堆栈小部件,CircleAvatar会为您处理。

CircleAvatar(backgroundColor: contentWithIcon[value]['color'], 
             child: Image.asset("assets/img/forex.png "),)

确保在pubspec.yaml中添加了资产文件夹

  assets:
    - assets/