hasDrawer method

bool hasDrawer (BuildContext context, { bool registerForUpdates: true })

Whether the Scaffold that most tightly encloses the given context has a drawer.

If this is being used during a build (for example to decide whether to show an "open drawer" button), set the registerForUpdates argument to true. This will then set up an InheritedWidget relationship with the Scaffold so that the client widget gets rebuilt whenever the hasDrawer value changes.

See also:

  • Scaffold.of, which provides access to the ScaffoldState object as a whole, from which you can show snackbars, bottom sheets, and so forth.

Implementation

static bool hasDrawer(BuildContext context, { bool registerForUpdates = true }) {
  assert(registerForUpdates != null);
  assert(context != null);
  if (registerForUpdates) {
    final _ScaffoldScope scaffold = context.inheritFromWidgetOfExactType(_ScaffoldScope);
    return scaffold?.hasDrawer ?? false;
  } else {
    final ScaffoldState scaffold = context.ancestorStateOfType(const TypeMatcher<ScaffoldState>());
    return scaffold?.hasDrawer ?? false;
  }
}