Skip to content

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

Merged
auto-submit[bot] merged 16 commits into
flutter:masterfrom
rrousselGit:null-item-builder
Sep 20, 2022
Merged

Re-add the ability to return null in ListView.builder#108706
auto-submit[bot] merged 16 commits into
flutter:masterfrom
rrousselGit:null-item-builder

Conversation

@rrousselGit

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread packages/flutter/lib/src/widgets/scroll_view.dart Outdated
@rrousselGit

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Sorry, I missed your message!

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

@goderbauer

Copy link
Copy Markdown
Member

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

@rrousselGit

Copy link
Copy Markdown
Contributor Author

Oops, sorry for the delay. Done

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread packages/flutter/lib/src/widgets/scroll_view.dart Outdated
Comment thread packages/flutter/lib/src/widgets/scroll_view.dart Outdated

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/flutter/lib/src/widgets/page_view.dart Outdated
/// [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
Copy Markdown
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
Copy Markdown
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

Comment thread packages/flutter/lib/src/widgets/scroll_view.dart Outdated
@rrousselGit

Copy link
Copy Markdown
Contributor Author

Oh, my bad. Let me fix that

@Piinks

Piinks commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

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!

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

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

auto-submit Bot commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

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

auto-submit Bot commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

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

@Piinks

Piinks commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

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

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread packages/flutter/lib/src/widgets/scroll_view.dart
@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

@galiperkin galiperkin left a comment

Copy link
Copy Markdown

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