Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stackTrace to AsyncSnapshot #69507

Open

Conversation

@creativecreatorormaybenot
Copy link
Contributor

@creativecreatorormaybenot creativecreatorormaybenot commented Oct 31, 2020

Description

This PR adds a stackTrace member that allows to trace errors in StreamBuilder and FutureBuilder. Previously, errors were not tracable in said widgets.

The stackTrace member is always specified when the error member is also specified.

Non-breaking

The stackTrace is a new optional parameter for AsyncSnapshot.withError; if not specified, StackTrace.empty will be used, which aligns with what stream controllers, completers, etc. do.

Related Issues

Tests

I added the following tests:

  • New tests specific to AsyncSnapshot.stackTrace in async_test.dart.
  • Updated existing tasks to reflect the onString changes in the same file.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • Nes, some existing tests failed, however, only because they depended on the toString method of AsyncSnapshot. User code should realistically not depend on toString because the class provides the members publicly.
…ck-trace
…ck-trace
@creativecreatorormaybenot creativecreatorormaybenot changed the title [WIP] Add stackTrace to AsyncSnapshot Add stackTrace to AsyncSnapshot Nov 2, 2020
@creativecreatorormaybenot creativecreatorormaybenot marked this pull request as ready for review Nov 2, 2020
Copy link
Contributor

@justinmc justinmc left a comment

This approach looks fine to me, but I've never used AsyncSnapshot before, so we should try to get another review from someone more knowledgeable. CC @tvolkert since I see your name in the git blame.

packages/flutter/lib/src/widgets/async.dart Outdated Show resolved Hide resolved
@@ -318,12 +343,12 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// of the following snapshots that includes the last one (the one with
/// ConnectionState.done):
///
/// * `new AsyncSnapshot<int>.withData(ConnectionState.waiting, null)`

This comment has been minimized.

@justinmc

justinmc Nov 2, 2020
Contributor

Good catch! This must be old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.