Skip to content

AppBar requires a Scaffold #8648

Closed

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.

Activity

  1. Hixie commented on Mar 8, 2017

    @Hixie
    Contributor

    AppBar needs a Scaffold ancestor, but it doesn't need to be the parent.

  2. added this to the milestone on Mar 16, 2017
  3. abarth commented on Mar 27, 2017

    @abarth
    Contributor

    See also #4581

  4. self-assigned this
    on Apr 3, 2017
  5. manujbahl commented on Mar 22, 2018

    @manujbahl

    How exactly do you add a appBar to a widget. Doesn't look like appBar can be a property on the Container or any other widget.

  6. github-actions commented on Aug 15, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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