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

Re-add the ability to return null in ListView.builder #108706

Merged
merged 16 commits into from
Sep 20, 2022

Conversation

rrousselGit
Copy link
Contributor

Fixes a possible regression during NNBD migration that removed the ability to return null in ListView.builder's itemBuilder

fixes #108705

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. labels Jul 31, 2022
@goderbauer
Copy link
Member

(from triage): Looks like some tests are failing on this, could you take a look and fix those up?

@goderbauer goderbauer requested a review from Piinks August 2, 2022 22:15
@rrousselGit
Copy link
Contributor Author

(from triage): Looks like some tests are failing on this, could you take a look and fix those up?

I'd happily try to fix the CI, but the error messages are unreadable

Example:

��������������������������������������������������������

Any thought on how I could get a readable explanation of the problem? Otherwise I'll have a hard time fixing the issue.

@goderbauer
Copy link
Member

The failure appears pretty clearly in the log [1]:

03:48 +2804 ~52: /tmp/flutter sdk/packages/flutter/test/widgets/scroll_view_test.dart: ListView.separated supports null items in itemBuilder                                                           
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: exactly 4 matching nodes in the widget tree
  Actual: _TextFinder:<5 widgets with text "separator" (ignoring offstage widgets):
Text("separator", dependencies: [DefaultSelectionStyle, DefaultTextStyle, MediaQuery]),
Text("separator", dependencies: [DefaultSelectionStyle, DefaultTextStyle, MediaQuery]),
Text("separator", dependencies: [DefaultSelectionStyle, DefaultTextStyle, MediaQuery]), ...>
   Which: is too many
When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///tmp/flutter%20sdk/packages/flutter/test/widgets/scroll_view_test.dart:179:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
  file:///tmp/flutter%20sdk/packages/flutter/test/widgets/scroll_view_test.dart line 179
The test description was:
  ListView.separated supports null items in itemBuilder
════════════════════════════════════════════════════════════════════════════════════════════════════

[1] https://cirrus-ci.com/task/6670346764943360?logs=main#L801

@rrousselGit
Copy link
Contributor Author

Thanks! Weird that Github action doesn't render them clearly. I'll look into it

@goderbauer goderbauer requested a review from Piinks August 16, 2022 22:13
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. So we have updated PageView, ListView, and GridView here, and it looks like AnimatedList, ReorderableList are confirmed not relevant.
It also looks like CupertinoTabScaffold specifies in the docs that tabBuilder cannot be null.

For the three cases that are changing to NullableIndexedWidgetBuilder can you add a templated doc that clarifies the behavior when using null to indicate the end of the list? The max scroll extent will not be accurate unless you are at the end of the list for example. This has caused confusion for a lot of folks in the past, so reintroducing this gives us a better chance to document it. :)

@rrousselGit
Copy link
Contributor Author

Sorry, I missed your message!

I'll update the docs after the Flutter Vikings (1st of September).

@goderbauer
Copy link
Member

(triage): @rrousselGit Do you have another chance to look at this now that Vikings is over?

@rrousselGit
Copy link
Contributor Author

Oops, sorry for the delay. Done

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM with nits, but it looks like CI is unhappy. Can you rebase with master to see if it resolves the failures?

packages/flutter/lib/src/widgets/scroll_view.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/widgets/scroll_view.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! The docs test looks unhappy, but I've noted where the issues are below.

packages/flutter/lib/src/widgets/page_view.dart Outdated Show resolved Hide resolved
/// list view's children are created in advance, or all at once when the
/// [ListView] itself is created, it is more efficient to use the [ListView]
/// constructor. Even more efficient, however, is to create the instances on
/// demand using this constructor's `itemBuilder` callback.
///
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an /// {@endtemplate}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one, it is in the paragraph above

This paragraph isn't part of the @template

packages/flutter/lib/src/widgets/scroll_view.dart Outdated Show resolved Hide resolved
@rrousselGit
Copy link
Contributor Author

Oh, my bad. Let me fix that

@Piinks
Copy link
Contributor

Piinks commented Sep 19, 2022

Oh, my bad. Let me fix that

No worries, appeasing the CI gods can feel a bit tedious at times. Thanks for sticking with it!

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flutter_LGTM

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 19, 2022
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 19, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 19, 2022

auto label is removed for flutter/flutter, pr: 108706, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 19, 2022

auto label is removed for flutter/flutter, pr: 108706, due to Validations Fail.

@Piinks
Copy link
Contributor

Piinks commented Sep 19, 2022

Ah we need a second reviewer, I'll seek one.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Piinks Piinks added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Sep 20, 2022
@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 20, 2022
@auto-submit auto-submit bot merged commit 6f3168c into flutter:master Sep 20, 2022
@rrousselGit rrousselGit deleted the null-item-builder branch September 20, 2022 19:03
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 21, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Sep 21, 2022
Copy link

@galiperkin galiperkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are reviewed. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: ListView.builder's itemBuilder can no-longer return null since NNBD migration
5 participants