vefhp.blogg.se

Flutter scaffold open drawer without key
Flutter scaffold open drawer without key








Here is my code: leading: new Container( child: new Image. But after I change it, this leading image counldn't open drawer. MainAxisAlignment: MainAxisAlignment. I want to change leading icon in AppBar to an image (user profile image). return Scaffold( drawer: Drawer(), key: scaffoldKey ) Now, in your initState method, add a PostFrameCallback to schedule the opening of the side drawer as soon as the widget tree has finished rendering. Add this key to your scaffold widget inside the build method. It would be nice if there was a component that allowed the use of Drawer without Scaffold, i use a global Material widget to have the background and avoid more rendering, but when it comes to the drawer it seems like im forced to use Scaffold to have a slidable drawer. From a random class, Id recommend passing. MainAxisAlignment: MainAxisAlignment.spaceAround, This key will be used to identify the scaffold state and interact with it. Hi, if you means a widget you can use: Scaffold.of(context).openDrawer(). Scaffold.of(context).openDrawer() / Scaffold.of(context).openEndDrawer().Scaffold class is important as it provides APIs for showing. I tried to add a key to the Scaffold widget and a leading icon, but it didnt work form me: GlobalKey< ScaffoldState. Listen Share Flutter scaffold drawer is implemented with primary material design visual layout structure. This worked very well Thanks a lot brother. You can openDrawer of global key from the flutter itself to do the job. I would like to change the default Scaffold drawer icon (hamburger icon). Here the solution is to use scaffoldKey to call openDrawer () so instead of doing Scaffold.of (context).openDrawer () you will do (), and do not forget to assign the key to your Scaffold, by doing key: scaffoldKey. Void openDrawer() build(BuildContext context) => Stack(ĭragStartBehavior: drawerDragStartBehavior, To close the drawer, use either ScaffoldState.closeEndDrawer, Navigator.

flutter scaffold open drawer without key flutter scaffold open drawer without key

#Flutter scaffold open drawer without key code

Here's my code Below for which Drawer dosen't appear class homieclass extends build(BuildContext context) ) : super(key: key) To open the drawer, use the ScaffoldState.openEndDrawer function. How do I get Drawer working with BottomAppBar? I've noticed that Drawer of Scaffold.drawer only shows up when an AppBar of Scaffold is present.īut Instead of AppBar,I Used BottomAppBar present in BottomNavigationBar.








Flutter scaffold open drawer without key