Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place Drawer widget on the right

Tags:

flutter

How to place Drawer widget on the right. Also is possible to place two Drawer widget in a single page one either side of the appbar

Widget build(BuildContext context){
 return Scaffold(
  drawer: Drawer(
    child: ListView(
      children: <Widget>[
        ListTile(
          leading: Icon(Icons.shopping_cart),
          title: Text('Checkout'),
          onTap: (){
            Navigator.pushNamed(context, '/home');
          },
        ),
        ListTile(
          leading: Icon(Icons.report),
          title: Text('Transactions'),
          onTap: (){
            Navigator.pushNamed(context, '/transactionsList');
          },
        ),
      ]
    )
  ),
  body: SingleChildScrollView(
    child: Column(
      children : [
        _buildOrderHeader(),
        _buildOrderDetails(context),
      ]
    )
  )
);

}'

like image 234
KURRU HEM Avatar asked Nov 14 '18 12:11

KURRU HEM


People also ask

How do you change the position of the drawer icon in Flutter?

To change the drawer icon in Flutter, add an IconButton widget inside the leading property of the AppBar widget. Inside the IconButton you can set any icon of your choice. Then, inside the onPressed of an IconButton, you can write a method to open the drawer.

What is drawer widget?

Drawer widget is used to provide access to different destinations and functionalities provided in your application. It is represented by three horizontal parallel lines on the upper end of the scaffold.


2 Answers

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

like image 91
Günter Zöchbauer Avatar answered Oct 12 '22 05:10

Günter Zöchbauer


  endDrawer:Drawer(child:Center(child:Columun(   children: <Widget>[
          Text('End Drawer)           ],
      ),))
  
like image 40
Osama Sandhu Avatar answered Oct 12 '22 05:10

Osama Sandhu