Home > Net >  Flutter: How to change the icon returned by navigation?
Flutter: How to change the icon returned by navigation?

Time:02-20

I am new in Flutter. I want to change the icon returned by navigation.

Screen1 Code:

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => Screen2(),
  ),
);

Screen2 Code:

Scaffold(
  appBar: AppBar(),
  body: Container(),
),

CodePudding user response:

The AppBar() widget has a leading property where you can customize the navigation icon.

Here's an example:

      AppBar(
        leading: IconButton(
            onPressed: () {
              Navigator.pop(context);
            },
            icon: const Icon(
              Icons.menu_rounded,
            ),
         ),
      ),

Check this helpful documentation for Material App Bars: https://material.io/components/app-bars-top/flutter

  • Related