I need to display a Scaffold drawer only for the portrait mode of some specific devices. I'm using conditional rendering (the showDrawer is true when the specific devices are met)
Scaffold( key: _scaffoldKey, drawer: showDrawer ? drawer : null, body: Text('test') )
This is not breaking the app (it works) but it is giving me a console error when I rotate the devices
════════ Exception caught by widgets library The following assertion was thrown while finalizing the widget tree: setState() or markNeedsBuild() called when widget tree was locked. This Scaffold widget cannot be marked as needing to build because the framework is locked.
I tried changing the conditional to:
drawer: showDrawer ? drawer : const SizedBox(),
but then the drawer overlay displays and hides the UI. Removing the conditional makes the console error disappear.
Any ideas on how can I solve this?