You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
Hixie commentedon Mar 8, 2017
AppBar needs a Scaffold ancestor, but it doesn't need to be the parent.
abarth commentedon Mar 27, 2017
See also #4581
manujbahl commentedon Mar 22, 2018
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.
github-actions commentedon Aug 15, 2021
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 -vand a minimal reproduction of the issue.