Search code examples
flutterflutter-layout

How to close Drawer upon button click(close) in flutter?


Is there a method to close drawer if clicked on a close button created on the top right corner of the drawer.

Mock of drawer:

drawer mock


Solution

  • Just call Navigator.of(context).pop();

    Example:

    ListTile(
      title: Text('Item 1'),
      onTap: () {
        // Update the state of the app.
        // ...
        // Then close the drawer.
        Navigator.pop(context);
      },
    ),
    

    References