Search code examples
flutteruser-interfacenavigationswipedrawer

How to prevent EndDrawer closing automatically by outside click in flutter like barrier dismissible in Dialog


I want to prevent End Drawer from closing automatically by clicking outside because if the user accidentally clicks outside of drawer it closes the drawer which is not that great because user filling form or interacting with data in End drawer, I have a close button on the top right of drawer which helps users to close drawer but I do not want to close drawer automatically by outside click, pls help your help will be appreciated


Solution

  • I used the solution from here https://stackoverflow.com/a/71391819

    For endDrawer you just need to add mainAxisAlignment.end in Row

    return Scaffold(
      ...,
      drawer: Container(
              color: Colors.transparent,
              child:
                  Row(mainAxisAlignment: MainAxisAlignment.end, 
    children: const [SizedBox(width: 304, child: DrawerMenu())])),
      ...
    );