Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在颤振中创建不失真的圆形图像_Flutter - Fatal编程技术网

Flutter 如何在颤振中创建不失真的圆形图像

Flutter 如何在颤振中创建不失真的圆形图像,flutter,Flutter,我需要创建一个圆形图像,但当它在容器中显示时,我使用的照片是变形的,它显示得非常糟糕 使用此代码 Container( height: 100, width: 100, decoration: BoxDecoration( border: Border.all(color: Colors.blueAccent),

我需要创建一个圆形图像,但当它在容器中显示时,我使用的照片是变形的,它显示得非常糟糕

使用此代码

Container(
                    height: 100,
                    width: 100,
                    decoration: BoxDecoration(
                      border: Border.all(color: Colors.blueAccent),
                      borderRadius: BorderRadius.circular(50),
                      image: DecorationImage(
                        image: FileImage(photoImage),
                        fit: BoxFit.fill,
                      ),
                    ),
                  )
CircleAvatar(
  radius: 40,
  child: ClipOval(
    child: Image(
      height: 100,
      fit: BoxFit.fill,
      image: FileImage(photoImage),
    ),
  ),
)
我还提供了这个代码

Container(
                    height: 100,
                    width: 100,
                    decoration: BoxDecoration(
                      border: Border.all(color: Colors.blueAccent),
                      borderRadius: BorderRadius.circular(50),
                      image: DecorationImage(
                        image: FileImage(photoImage),
                        fit: BoxFit.fill,
                      ),
                    ),
                  )
CircleAvatar(
  radius: 40,
  child: ClipOval(
    child: Image(
      height: 100,
      fit: BoxFit.fill,
      image: FileImage(photoImage),
    ),
  ),
)

非常感谢您的帮助。

我建议使用Circle avatar,这样会更好 对于资产映像

CircleAvatar(backgroundImage: FileImage(photoImage), radius: 55.0)
具有网络图像的圆电视

  CircleAvatar(
    backgroundImage: 
    NetworkImage('https://www.woolha.com/media/2020/03/eevee.png'),
    minRadius: 50,
    maxRadius: 75,
  )

非常糟糕的是,我假设你指的是图像扭曲的纵横比。您可能需要使用
BoxFit.cover
<已知代码>BoxFit.fill会根据


BoxFit.cover
,另一方面,在尽可能小的情况下保持纵横比。

同样,图像会失真