debugCheckHasFluentTheme function
Asserts that the given context has a FluentTheme ancestor.
To call this function, use the following pattern, typically in the relevant Widget's build method:
assert(debugCheckHasFluentTheme(context));
Does nothing if asserts are disabled. Always returns true.
Implementation
bool debugCheckHasFluentTheme(BuildContext context, [bool check = true]) {
assert(() {
if (context.maybeTheme == null)
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('A FluentTheme widget is necessary to draw this layout.'),
ErrorHint(
'To introduce a FluentTheme widget, you can either directly '
'include one, or use a widget that contains FluentTheme itself, '
'such as FluentApp',
),
...context.describeMissingAncestor(expectedAncestorType: FluentTheme),
]);
return true;
}());
return true;
}