2

flutter, what is the right way to change appbar leading icon at app theme level? so I no need to change on each screen?

I know the following code work for specific screen...

AppBar(
  title: Text("Hello Appbar"),
  leading: Icon(
    Icons.arrow_back,
  ),
);

but I don't want to do it on each screen, Just checking here if I can set it at app theme level so it is same for all screen...

I referred flutter documentation for appbar, but it was not much helpful.

ramya
  • 121
  • 9

2 Answers2

0

You can do something like this

import 'package:flutter/material.dart';

AppBar MyAppBar({Widget title, Widget leading}) {
  return AppBar(
    title: title,
    leading: leading,
  );
}
Amirul Abu
  • 26
  • 3
-1

Use IconButton to change the leading icon.

 AppBar(
  title: Text("Hello Appbar"),
  leading: IconButton(
   onPressed: () {},
   icon: Icon(Icons.arrow_back)
  ),
);