context property
final
A DiagnosticsNode that provides a human-readable description of where the error was caught (as opposed to where it was thrown).
The node, e.g. an ErrorDescription, should be in a form that will make sense in English when following the word "thrown", as in "thrown while obtaining the image from the network" (for the context "while obtaining the image from the network").
This is an example of using and ErrorDescription as the
FlutterErrorDetails.context when calling FlutterError.reportError.
link
void maybeDoSomething() {
try {
// Try to do something!
} catch (error) {
// Catch & report error.
FlutterError.reportError(FlutterErrorDetails(
exception: error,
library: 'Flutter test framework',
context: ErrorDescription('while dispatching notifications for $runtimeType'),
));
}
}
See also:
- ErrorDescription, which provides an explanation of the problem and its cause, any information that may help track down the problem, background information, etc.
- ErrorSummary, which provides a short (one line) description of the problem that was detected.
- ErrorHint, which provides specific, non-obvious advice that may be applicable.
- FlutterError, which is the most common place to use FlutterErrorDetails.
Implementation
final DiagnosticsNode? context;