首页 > 解决方案 > 如何在颤动中增加 AssetImage 中图像的大小?

问题描述

我正在创建一个导航栏,我在这里放置了不同的图像作为图标,如何在这里增加图像大小。图像存在于 ImageIcon 内的 Assetimage 中。当我尝试使用 ImageIcon 中的大小来增加图像大小时,它不起作用.

 Container(
                    width: size.width,
                    height: 80,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        IconButton(
                          icon: ImageIcon(
                            AssetImage(
                              'assets/about.png',
                            ),
                            color:
                                currentIndex == 0 ? Colors.blue : Colors.black,
                          ),
                          onPressed: () {
                            setBottomBarIndex(0);
                          },
                          splashColor: Colors.white,
                        ),
                        IconButton(
                            icon: ImageIcon(
                              AssetImage('assets/skills.png'),
                              color: currentIndex == 1
                                  ? Colors.blue
                                  : Colors.black,
                            ),
                            onPressed: () {
                              setBottomBarIndex(1);
                            }),
                        Container(
                          width: size.width * 0.20,
                        ),
                        IconButton(
                            icon: ImageIcon(
                              AssetImage('assets/projects.png'),
                              color: currentIndex == 2
                                  ? Colors.blue
                                  : Colors.black,
                            ),
                            onPressed: () {
                              setBottomBarIndex(2);
                            }),
                        IconButton(
                            icon: ImageIcon(
                              AssetImage('assets/blog.png'),
                              color: currentIndex == 3
                                  ? Colors.blue
                                  : Colors.black,
                            ),
                            onPressed: () {
                              setBottomBarIndex(3);
                            }),
                      ],
                    ),
              )

标签: androidimageflutterdartflutter-layout

解决方案


用 Transform.scale 包裹你的图标按钮:

Transform.scale(scale: 2.5 ,child: IconButton(icon: ImageIcon(AssetImage('assets/about.png'), size: 50,) , onPressed: null)),


推荐阅读