颤动的网格视图显示一些间距

时间:2020-11-06 14:28:07

标签: flutter

我在我的应用程序中使用Gridview,所以我需要水平和垂直对齐。因此,我将背景色更改为灰色,但是问题在于它显示了一些额外的空间,该如何删除呢?

Container(
                    color: Colors.grey,
                    child: GridView(
                      shrinkWrap: true,
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisSpacing: 2,
                        mainAxisSpacing: 2,
                        crossAxisCount: 4,
                      ),
                      children: <Widget>[
                        Container(
                          color: Colors.white,
                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat1.png'),
                              ),
                              SizedBox(height: Height * 0.008,),
                              Text(
                                'Computer Hardware',
                                textAlign: TextAlign.center,
                              )
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,

                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat2.png'),
                              ),
                              SizedBox(height: Height * 0.008,),

                              Text('Computer Software',
                                  textAlign: TextAlign.center)
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,

                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat3.png'),
                              ),
                              SizedBox(height: Height * 0.008,),


                              Text('Internet', textAlign: TextAlign.center)
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,

                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat4.png'),
                              ),
                              SizedBox(height: Height * 0.008,),

                              Text('Mobile / Table & iPad',
                                  textAlign: TextAlign.center)
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,

                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat5.png'),
                              ),
                              SizedBox(height: Height * 0.008,),

                              Text(
                                'Printer & Scanner',
                                textAlign: TextAlign.center,
                              )
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,

                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat6.png'),
                              ),
                              SizedBox(height: Height * 0.008,),

                              Text('CCTV Cameras', textAlign: TextAlign.center)
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,

                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),

                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat7.png'),
                              ),
                              SizedBox(height: Height * 0.008,),

                              Text('Smart TV/Home Theater',
                                  textAlign: TextAlign.center)
                            ],
                          ),
                        ),
                        Container(
                          color: Colors.white,
                          child: Column(
                            children: [
                              SizedBox(height: Height * 0.01,),
                              Container(
                                height: Height * 0.04,
                                child: Image.asset('images/cat8.png'),
                              ),
                              SizedBox(height: Height * 0.008,),

                              Text('E-Learning', textAlign: TextAlign.center)
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),

enter image description here

您可以在图像中看到其顶部显示为灰色,我需要将其删除。我没有在容器中使用任何填充等,​​仍然显示

1 个答案:

答案 0 :(得分:0)

设置gridview填充:const EdgeInsets.all(0)