如何制作带有按钮的图像图标来更改图像 google:

How to make an Image Icon with a button to change the image like google:

我想在我的个人资料屏幕中创建一个用户的个人资料照片,该照片用一个按钮四舍五入,或者用一些有创意的东西来改变这张照片,比如 google:

但我现在拥有的是:

CircleAvatar(
  radius: 75,
  backgroundColor: Colors.grey.shade200,
  child: CircleAvatar(
    radius: 70,
    backgroundImage: AssetImage('assets/images/default.png'),
  )
),

如何像 google 示例中那样添加按钮?

您可以使用带有 Positioned 的 Stack 小部件作为其子小部件。

使用Stack你可以将图标放在头像顶部的特定位置。

Stack(
      children: [
        CircleAvatar(
          radius: 75,
          backgroundColor: Colors.grey.shade200,
          child: CircleAvatar(
            radius: 70,
            backgroundImage: AssetImage('assets/images/default.png'),
          ),
        ),
        Positioned(
          bottom: 1,
          right: 1,
          child: Container(
            child: Padding(
              padding: const EdgeInsets.all(2.0),
              child: Icon(Icons.add_a_photo, color: Colors.black),
            ),
            decoration: BoxDecoration(
                border: Border.all(
                  width: 3,
                  color: Colors.white,
                ),
                borderRadius: BorderRadius.all(
                  Radius.circular(
                    50,
                  ),
                ),
                color: Colors.white,
                boxShadow: [
                  BoxShadow(
                    offset: Offset(2, 4),
                    color: Colors.black.withOpacity(
                      0.3,
                    ),
                    blurRadius: 3,
                  ),
                ]),
          ),
        ),
      ],
    )