Flutter 颤振增加栅格视图中的容器高度

Flutter 颤振增加栅格视图中的容器高度,flutter,Flutter,我使用的是网格视图,我需要显示一个3x3容器。问题是我无法设置容器的高度,因为它没有增加和剪切内容 我的代码 Container( padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children

我使用的是网格视图,我需要显示一个3x3容器。问题是我无法设置容器的高度,因为它没有增加和剪切内容

我的代码

Container(
                    padding: EdgeInsets.all(10),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        RichText(
                          text: new TextSpan(
                            // Note: Styles for TextSpans must be explicitly defined.
                            // Child text spans will inherit styles from parent
                            style: new TextStyle(
                              fontSize: 14.0,
                              color: Colors.black,
                            ),
                            children: <TextSpan>[
                              new TextSpan(
                                  text: 'Service ',
                                  style: new TextStyle(
                                      fontWeight: FontWeight.bold,
                                      fontSize: 22)),
                              new TextSpan(
                                  text: 'Deals',
                                  style: TextStyle(fontSize: 18)),
                            ],
                          ),
                        ),
                        Container(
                          width: Width * 0.1,
                          height: Height * 0.05,
                          decoration: BoxDecoration(
                            image: DecorationImage(
                              image: AssetImage("images/see.png"),
                            ),
                          ),
                        ),


                      ],
                    ),
                  ),

                  Container(
                    child: GridView(
                      padding: EdgeInsets.all(0),
                      shrinkWrap: true,
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

                        crossAxisCount: 3,
                      ),
                      children: [
                        Card(
                          child: Container(
                            child: Column(
                              children: [
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Container(
                                      height: Height * 0.025,
                                      child: Image.asset('images/heartfill.png'),

                                    ),
                                    Container(
                                      height: Height * 0.025,
                                      color: Color(0xffD4E6F1),
                                      child: Image.asset('images/add.png'),

                                    )
                                  ],
                                ),
                                Container(
                                  height: Height * 0.11,
                                  child: Image.asset('images/hp.png'),
                                ),
                                Expanded(
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceBetween,

                                    children: [
                                      Container(
                                        child: Text('\$45'),
                                      ),
                                      Row(
                                        children: [
                                          Container(
                                            height: Height * 0.02,
                                            child: Image.asset('images/star.png'),
                                          ),
                                          Container(
                                            child: Text('4.4'),
                                          )

                                        ],
                                      )
                                    ],
                                  ),
                                )
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  )
容器(
填充:边缘设置。全部(10),
孩子:排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
RichText(
text:newtextspan(
//注意:必须明确定义TextSpans的样式。
//子文本跨距将从父文本跨距继承样式
样式:新文本样式(
字体大小:14.0,
颜色:颜色,黑色,
),
儿童:[
新文本跨度(
文本:“服务”,
样式:新文本样式(
fontWeight:fontWeight.bold,
尺寸:22),,
新文本跨度(
文本:“交易”,
样式:TextStyle(fontSize:18)),
],
),
),
容器(
宽度:宽度*0.1,
高度:高度*0.05,
装饰:盒子装饰(
图像:装饰图像(
图像:AssetImage(“images/see.png”),
),
),
),
],
),
),
容器(
子:GridView(
填充:边缘集。全部(0),
收缩膜:对,
gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(
交叉轴计数:3,
),
儿童:[
卡片(
子:容器(
子:列(
儿童:[
划船(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
容器(
高度:高度*0.025,
子级:Image.asset('images/heartfill.png'),
),
容器(
高度:高度*0.025,
颜色:颜色(0xffD4E6F1),
子项:Image.asset('images/add.png'),
)
],
),
容器(
高度:高度*0.11,
子项:Image.asset('images/hp.png'),
),
扩大(
孩子:排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
容器(
子项:文本(“\$45”),
),
划船(
儿童:[
容器(
高度:高度*0.02,
子级:Image.asset('images/star.png'),
),
容器(
子项:文本('4.4'),
)
],
)
],
),
)
],
),
),
)
],
),
)
我需要实现这种类型的盒子

我也做过类似的事情,但是它会裁剪我需要增加容器高度的内容,这就是问题所在


只需使用SliverGridDelegateWithFixedCrossAxisCount的childAspectRatio属性来设置每个子级的横轴与主轴范围的比率。 前


它实际上是网格视图子级的宽高比。请相应地调整它。

只需使用SliverGridDelegateWithFixedCrossAxisCount的childAspectRatio属性,即可设置每个子级的横轴与主轴范围的比率。 前

它实际上是栅格视图子视图的宽高比。请相应调整它

gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 3,
                        childAspectRatio:0.8
                      ),