Search code examples
androidimageflutterdartflutter-layout

How to increase the size of image in AssetImage here in flutter?


I am creating a Navigation bar and I have put different images as icon in here,How can I increase image size here.The image is present in Assetimage inside ImageIcon.When I try to increase the image size using size in ImageIcon,it doesnt work.

 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);
                            }),
                      ],
                    ),
              )

Solution

  • Wrap your icon button with Transform.scale:

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