flutterdartappbar

How to increase on the size of the leading icon off an AppBar flutter


I am looking for a way of increasing the size of Appbar leading Icon. Below is my code :

appBar: PreferredSize(
              preferredSize: Size.fromHeight(120.0),
              child: AppBar(
                leading: SizedBox(
                  width: 200,
                height: 200,
                child: IconButton(
                  padding: new EdgeInsets.all(0.0),
                  icon: Image.asset('assets/app_logo.png', height: 700.0, width: 700.0,)
                  ,
                )),
            centerTitle: true,
            actions: <Widget>[
              IconButton(
                  icon: Image.asset('assets/path.png'))
            ],
            bottom: TabBar(
                labelColor: Colors.white,
                indicatorColor: Colors.lime,

                tabs:[
                  Tab(icon: null,text: 'RECENT',),
                  Tab(icon: null, text: 'TOPICS',),
                  Tab(icon: null, text: 'AUTHORS',),
                ]
            ),
          )

From the code above, specifically the size I implemented is below, but it couldn't work :

child: AppBar(
                    leading: SizedBox(
                      width: 200,
                    height: 200,
                    child: IconButton(
                      padding: new EdgeInsets.all(0.0),
                      icon: Image.asset('assets/app_logo.png', height: 700.0, width: 700.0,)
                      ,
                    )),

My goal is to increase the Right top icon more bigger, but it doesn't increase it's size.

The screenshot is as below :

enter image description here


Solution

  • You can increase the size of the icon by wrapping IconButton with Transform.scale and pass scale value as 2, depending on how big you want the icon to be. Working sample code below:

    centerTitle: true,
                    actions: <Widget>[
                      Transform.scale(
                        scale: 2,
                        child: IconButton(
                            icon: Image.asset('assets/placeholder.png'))
                      ),
    
                    ],
    

    This increases size of the top right icon in the appbar, as:

    enter image description here

    You may adjust the scale per your need and also can apply same change to top left icon too.

    Hope this answers your question.