Flutter: изменение размера дочерних элементов в SliverGrid

Я пытаюсь создать BottomSheet, где в сетке отображаются разные смайлики, изображения и гифки. Для этого я использую виджет CustomScrollView с SliverPadding и SliverGrid. Моя проблема в том, что я не могу настроить размер изображений и гифок в сетке. Размер смайликов можно легко изменить с помощью свойства fontSize.

Вот мой код на данный момент:

 CustomScrollView(
                          physics: NeverScrollableScrollPhysics(),
                          primary: false,
                          slivers: <Widget>[
                            SliverPadding(
                              padding: const EdgeInsets.only(top: 40.0),
                              sliver: SliverGrid.count(
                                crossAxisSpacing: 50.0,
                                crossAxisCount: 3,

                                children: <Widget>[
                                  GestureDetector(
                                    child: const Text('????', textAlign: TextAlign.center, style: TextStyle(fontSize: 30.0)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "like");
                                      Navigator.pop(context);
                                    },
                                  ),
                                  GestureDetector(
                                    child: const Text('????', textAlign: TextAlign.center, style: TextStyle(fontSize: 30.0)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "laugh");
                                      Navigator.pop(context);
                                    },
                                  ),
                                  GestureDetector(
                                    child: const Text('????', textAlign: TextAlign.center, style: TextStyle(fontSize: 30.0)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "surprised");
                                      Navigator.pop(context);
                                    },
                                  ),
                                  GestureDetector(
                                    child: const Text('????', textAlign: TextAlign.center, style: TextStyle(fontSize: 30.0)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "hot");
                                      Navigator.pop(context);
                                    },
                                  ),
                                  GestureDetector(
                                    child: const Text('????????', textAlign: TextAlign.center, style: TextStyle(fontSize: 30.0)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "thumbsUp");
                                      Navigator.pop(context);
                                    },

                                  ),
                                  GestureDetector(
                                    child: const Text('????????', textAlign: TextAlign.center, style: TextStyle(fontSize: 30.0)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "nice");
                                      Navigator.pop(context);
                                    },

                                  ),
                                  GestureDetector(
                                    child: SizedBox(
                                              height: 20,
                                              width: 20,

                                    child:  Image.asset('assets/kiss.gif', height: 20, width: 20, fit: BoxFit.fill)),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "nice");
                                      Navigator.pop(context);
                                    },

                                  ),
                                ],
                              ),
                            ),
                          ],

                       )

А вот как это выглядит в настоящий момент (губы поцелуя на самом деле движутся):

введите описание изображения здесь

Как видите, поцелуй - это слишком много, но я не могу отрегулировать его размер. Будь то высота и ширина или упаковка в SizedBox, ничего не работало.

Любые идеи?

С наилучшими пожеланиями.


person Martin Seubert    schedule 07.05.2019    source источник


Ответы (1)


Я решил это, обернув дочерние элементы в Center Widgets:

 GestureDetector(
       child: Center(
         child:  Container(
                      height: 50,
                      width: 50,
                         child:  Image.asset('assets/kiss.gif')),
                                    onTap: (){
                                      postLike(widget.list[widget.index].reference, widget.currentUser, "kiss");
                                      Navigator.pop(context);
                                    },

                                  ),
person Martin Seubert    schedule 07.05.2019