How to place Drawer widget on the right
To open navigation drawer from right side with Dart Null Safety, You should use endDrawer(). There is two drawer arguments available in flutter.
- Drawer (left side)
- endDrawer (Right side) you can see the example for endDrawer.
To open endDrawer on Button click.
_scaffoldKey.currentState!.openEndDrawer();
Create Global Key
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
inside Build()
Scaffold(
backgroundColor: backgroundcolor_cust,
key: _scaffoldKey,
endDrawer: Drawer(
elevation: 16.0,
child: leftDrawerMenu(context, user_phone, cart_count),
),
endDrawer:Drawer(child:Center(child:Columun( children: <Widget>[
Text('End Drawer) ],
),))
By using endDrawer: ...
instead or in addition to drawer: ...
to set a drawer, like this:
Scaffold(
endDrawer: Drawer(...),
// ...
)
To open it programmatically, use
Scaffold.of(context).openEndDrawer(); //This might have been updated by flutter team since the last edit
See also https://docs.flutter.io/flutter/material/Scaffold/endDrawer.html