buildDocumentFailure function

Widget buildDocumentFailure(
  1. BuildContext context, {
  2. required VyuhFailure failure,
  3. required bool isRoute,
  4. VoidCallback? onRetry,
})

Shows failure: a full page with Back and Go home for routes, or an inline card for content inside a page.

Route failures report themselves once through RouteFailureView. Inline failures are reported by the caller when they happen, so nothing is reported from build.

Implementation

Widget buildDocumentFailure(
  BuildContext context, {
  required VyuhFailure failure,
  required bool isRoute,
  VoidCallback? onRetry,
}) {
  if (isRoute) {
    return RouteFailureView(
      key: ObjectKey(failure),
      failure: failure,
      onRetry: onRetry,
    );
  }

  return VyuhFailureScope(
    failure: failure,
    child: Builder(
      builder: (context) => vyuh.widgetBuilder.errorView(
        context,
        title: failure.title,
        subtitle: failure.message,
        error: failure.error,
        stackTrace: failure.stackTrace,
        onRetry: onRetry,
      ),
    ),
  );
}