Home > Blockchain >  How to change icon in AppBarWidget in flutter?
How to change icon in AppBarWidget in flutter?

Time:04-24

I have this AppBarWidget and I need to change the arrow back logo to my custom svg icon. I'm new in flutter and I can't find how to change it.

Here is code for AppBar

    return AppBar(
      elevation: 0,
      backgroundColor: white,
      foregroundColor: black,
      shadowColor: Colors.transparent,
      toolbarHeight: 80,
      titleTextStyle: getCustomeStyle(
          fontSize: 25, fontWeight: FontWeight.w700, color: black),
      title: FittedBox(
          fit: BoxFit.fill,
          child: SizedBox(
            width: _width,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(title),                
                  SvgPicture.asset("assets/images//logo/ShopIO.svg",
                      semanticsLabel: "ShopIO")
              ],
            ),
          )),
      bottom: PreferredSize(
          child: Container(
            color: lightGray,
            height: 1.0,
            width: _width - 30,
          ),
          preferredSize: const Size.fromHeight(0)),
    );

CodePudding user response:

The easiest way is to override the deafult leading widget of AppBar and add your custom:

AppBar(
  leading: IconButton(
    icon: <whatever you like>,
    // this is the default behaviour, you can change it
    onPressed: () => Navigator.of(context).pop()
  ),

CodePudding user response:

AppBar( leading: IconButton( icon: Icon( Icons.list, ), onPressed: (){print("Icon change");}, ), ),

  • Related