Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
Image 装饰图像/作为子对象的图像是否在容器外部?_Image_Flutter - Fatal编程技术网

Image 装饰图像/作为子对象的图像是否在容器外部?

Image 装饰图像/作为子对象的图像是否在容器外部?,image,flutter,Image,Flutter,我试过这些 1.装饰图像 2.形象 3.圆形 我已经使用堆栈,因为将有一个背景图像。 但我无法理解为什么图像会像那样扩展 我需要一个圆形的个人资料图片图像 如果我使用列而不是ListView,那么图像不会像这样展开…但我需要一个ListView 守则:- @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: <Widget>

我试过这些 1.装饰图像 2.形象 3.圆形

我已经使用堆栈,因为将有一个背景图像。 但我无法理解为什么图像会像那样扩展

我需要一个圆形的个人资料图片图像

如果我使用列而不是ListView,那么图像不会像这样展开…但我需要一个ListView

守则:-

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[
          ListView(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Container(
                  height: 80.0,
                  width: 80.0,
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    image: new DecorationImage(
                      image: AssetImage(Assets.cool),
                      fit: BoxFit.cover,
                    ),
                    color: Colors.red,
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Container(
                  height: 50.0,
                  width: 50.0,
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                  ),
                  child: Image(
                    image: AssetImage(Assets.cool),
                    fit: BoxFit.cover,
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: CircleAvatar(
                  radius: 50.0,
                  backgroundImage: AssetImage(Assets.cool),
                ),
              )
            ],
          )
        ],
      ),
    );
  }
@覆盖
小部件构建(构建上下文){
返回脚手架(
主体:堆栈(
儿童:[
列表视图(
儿童:[
填充物(
填充:常数边集全部(8.0),
子:容器(
身高:80.0,
宽度:80.0,
装饰:盒子装饰(
形状:BoxShape.circle,
图片:新装饰图片(
图片:AssetImage(Assets.cool),
适合:BoxFit.cover,
),
颜色:颜色,红色,
),
),
),
填充物(
填充:常数边集全部(8.0),
子:容器(
身高:50.0,
宽度:50.0,
装饰:盒子装饰(
形状:BoxShape.circle,
),
孩子:图像(
图片:AssetImage(Assets.cool),
适合:BoxFit.cover,
),
),
),
填充物(
填充:常数边集全部(8.0),
孩子:圆环星(
半径:50.0,
背景图片:AssetImage(Assets.cool),
),
)
],
)
],
),
);
}

据我所知,你希望图像是圆形而不是椭圆形。您可以通过使用
元素包装
列表视图
中的项目来实现这一点

return Scaffold(
  body: Stack(
    children: <Widget>[
      ListView(
        children: <Widget>[
          // Wrap with a row
          Row(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Container(
                  height: 80.0,
                  width: 80.0,
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    image: new DecorationImage(
                      image: AssetImage("a.jpg"),
                      fit: BoxFit.cover,
                    ),
                    color: Colors.red,
                  ),
                ),
              ),
              //...
            ],
          ),
        ],
      )
    ],
  ),
);  
返回脚手架(
主体:堆栈(
儿童:[
列表视图(
儿童:[
//一字排开
划船(
儿童:[
填充物(
填充:常数边集全部(8.0),
子:容器(
身高:80.0,
宽度:80.0,
装饰:盒子装饰(
形状:BoxShape.circle,
图片:新装饰图片(
图片:AssetImage(“a.jpg”),
适合:BoxFit.cover,
),
颜色:颜色,红色,
),
),
),
//...
],
),
],
)
],
),
);  

要获得一个圆形图像,只需将ListView的所有小部件包装在一个
小部件中,并将该列放在ListView中即可。您将得到一个可滚动的列

ListView(
    children: <Widget>[
      Column(
        children: <Widget>[
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              height: 80.0,
              width: 80.0,
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                image: new DecorationImage(
                  image: AssetImage(Assets.cool),
                  fit: BoxFit.cover,
                ),
                color: Colors.red,
              ),
            ),
          ),
          //.....
        ],
      )
    ],
  ),s
ListView(
儿童:[
纵队(
儿童:[
填充物(
填充:常数边集全部(8.0),
子:容器(
身高:80.0,
宽度:80.0,
装饰:盒子装饰(
形状:BoxShape.circle,
图片:新装饰图片(
图片:AssetImage(Assets.cool),
适合:BoxFit.cover,
),
颜色:颜色,红色,
),
),
),
//.....
],
)
],
),s