0

I have an appbar which is used in more than one screen. I have a navigation drawer in the home screen. As the appbar is used in multiple places, i created as a separate widget. But I am not able to access navigation drawer. So I included appbar code in all the screens I needed. Then it works fine. But it will be code duplicate. Is there any fix for this in Flutter?

Thanks.

1 Answers1

0

If you have not done so yet , you can make a separate class for drawer

getAppDrawer(){
  return Drawer(
    //your code
  );
}

and then you can call this in your others screen

drawer : getAppDrawer(),

you can also do this for the appbar

Take a look at the examples here

and here

yoad
  • 65
  • 6