Asserts that the given context has a Scaffold ancestor.
Used by some material design widgets to make sure that they are only used in contexts where they can communicate with a Scaffold.
For example, the AppBar in some situations requires a Scaffold to do the right thing with scrolling.
To call this function, use the following pattern, typically in the
relevant Widget's build
method:
assert(debugCheckHasScaffold(context));
Does nothing if asserts are disabled. Always returns true.
Source
bool debugCheckHasScaffold(BuildContext context) { assert(() { if (Scaffold.of(context) == null) { Element element = context; throw new FlutterError( 'No Scaffold widget found.\n' '${context.widget.runtimeType} widgets require a Scaffold widget ancestor.\n' 'The specific widget that could not find a Scaffold ancestor was:\n' ' ${context.widget}\n' 'The ownership chain for the affected widget is:\n' ' ${element.debugGetCreatorChain(10)}' ); } return true; }); return true; }