FlutterErrorDetails.context docs fix (#55001)

This commit is contained in:
Kate Lovett 2020-04-27 14:04:04 -07:00 committed by GitHub
parent 265168170d
commit c849ffd3b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,9 @@ import 'diagnostics.dart';
import 'print.dart';
import 'stack_frame.dart';
// Examples can assume:
// String runtimeType;
/// Signature for [FlutterError.onError] handler.
typedef FlutterExceptionHandler = void Function(FlutterErrorDetails details);
@ -281,7 +284,7 @@ class ErrorSummary extends _ErrorDiagnostic {
/// An [ErrorHint] provides specific, non-obvious advice that may be applicable.
///
/// If your message provides obvious advice that is always applicable it is an
/// If your message provides obvious advice that is always applicable, it is an
/// [ErrorDescription] not a hint.
///
/// See also:
@ -325,7 +328,30 @@ class ErrorSpacer extends DiagnosticsProperty<void> {
/// Class for information provided to [FlutterExceptionHandler] callbacks.
///
/// See [FlutterError.onError].
/// {@tool snippet}
/// This is an example of using [FlutterErrorDetails] when calling
/// [FlutterError.reportError].
///
/// ```dart
/// void main() {
/// try {
/// // Try to do something!
/// } catch (error) {
/// // Catch & report error.
/// FlutterError.reportError(FlutterErrorDetails(
/// exception: error,
/// library: 'Flutter test framework',
/// context: ErrorSummary('while running async test code'),
/// ));
/// }
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [FlutterError.onError], which is called whenever the Flutter framework
/// catches an error
class FlutterErrorDetails with Diagnosticable {
/// Creates a [FlutterErrorDetails] object with the given arguments setting
/// the object's properties.
@ -382,13 +408,45 @@ class FlutterErrorDetails with Diagnosticable {
/// the console.
final String library;
/// A human-readable description of where the error was caught (as opposed to
/// where it was thrown).
/// A [DiagnosticsNode] that provides a human-readable description of where
/// the error was caught (as opposed to where it was thrown).
///
/// The string 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").
/// 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").
///
/// {@tool snippet}
/// This is an example of using and [ErrorDescription] as the
/// [FlutterErrorDetails.context] when calling [FlutterError.reportError].
///
/// ```dart
/// 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'),
/// ));
/// }
/// }
/// ```
/// {@end-tool}
///
/// 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].
final DiagnosticsNode context;
/// A callback which filters the [stack] trace. Receives an iterable of