How to detect the outside in the image?
To open the drawer I already know its function, but to tap the right side of the drawer I don't know
Any help would be appreciated.
How to detect the outside in the image?
To open the drawer I already know its function, but to tap the right side of the drawer I don't know
Any help would be appreciated.
You can add a global boolean isSideBarOpen and make it true when it opens (best in the onPress() event of the button that opens it). And make sure to set it false again once it closes.
You can add a GestureDetector to the Scaffold like this:
body: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (isSideBarOpen) {
// sideBar.close();
}
}
This checks whether the sideBar is open or not and closes it – with the appropriate code – when you tap anywhere else on the screen.