Skip to content

AppBar requires a Scaffold #8648

@lukef

Description

@lukef

It appears that AppBar always requires a Scaffold. If you try to add an AppBar to a Widget that doesn't have a Scaffold you will get the following error:

Scaffold.of() called with a context that does not contain a Scaffold.

No Scaffold ancestor could be found starting from the context that was passed to 
Scaffold.of(). This usually happens when the context provided is from the same 
StatefulWidget as that whose build function actually creates the Scaffold widget 
being sought.

The documentation implies that it should be possible to use an AppBar outside of a Scaffold:

/// App bars are typically used in the [Scaffold.appBar] property, which places
/// the app bar as a fixed-height widget at the top of the screen.

It looks like there are a lot of cases where there are direct references to Scaffold.of(...) without checks.

Metadata

Metadata

Assignees

Labels

customer: posse (eap)d: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions