Skip to content

Conversation

@HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Jul 15, 2017

The NestedScrollView changes were contributed by @collinjackson

Fixes #10925
Fixes #11153

@HansMuller HansMuller changed the title [NOT FOR REVIEW] NestedScrollView changes Add a ScrollController parameter to NestedScrollView. Jul 17, 2017
@HansMuller HansMuller changed the title Add a ScrollController parameter to NestedScrollView. Add a ScrollController parameter to NestedScrollView Jul 17, 2017
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a test for this change?

Copy link
Contributor Author

@HansMuller HansMuller Jul 18, 2017

Choose a reason for hiding this comment

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

I've reverted this change. We'll probably revisit it in a future PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

why "parent"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It matches the similarly unqualified "updateParent()" method name.

Copy link
Contributor

Choose a reason for hiding this comment

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

what is the purpose of this change?

Copy link
Contributor

@collinjackson collinjackson Jul 17, 2017

Choose a reason for hiding this comment

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

Future.wait doesn't return null, so Flutter will throw an error in the logs complaining about a type mismatch.

Copy link
Contributor

Choose a reason for hiding this comment

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

See #10925

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. Is there a test that verifies this particular issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new tests are tripped up by this.

00:01 +3 ~1: - NestedScrollView with a ScrollController
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
type '_Future<List>' is not a subtype of type 'Future<Null>' of 'function result' where
  _Future is from dart:async
  List is from dart:core
  Future is from dart:async
  Null is from dart:core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to be clear: if I reintroduce the error, the new tests catch it.

Copy link
Contributor

Choose a reason for hiding this comment

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

great!

Copy link
Contributor

Choose a reason for hiding this comment

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

the "first" here is a bug factory. For example, what if there's a scroll view prior to this one in the layout? it'll be the first scroll position in the default scroll controller, but it has no particular relationship with this scroll view.

@HansMuller
Copy link
Contributor Author

I've eliminated the scrollController.positions.first hack and restored the @protected annotation to the positions method.

I added a TrackingScrollController class, which remembers the last scroll position that changed and reports its pixels value as the controller's initialScrollOffset. NestedScrollView now just uses its controller's initialScrollOffset to set up its _NestedScrollControllers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than returning 0.0 by default, return super.initialScrollOffset, and then have TrackingScrollController take an initialScrollOffset which it passes to the parent. That way, you can still set an initial scroll offset.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: space after colon

@Hixie
Copy link
Contributor

Hixie commented Jul 19, 2017

LGTM

@HansMuller HansMuller merged commit daa7860 into flutter:master Jul 19, 2017
@HansMuller HansMuller deleted the nested_scrolling branch July 19, 2017 14:50
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NestedScrollView should expose a controller NestedScrollView throws exception caused by type mismatch

4 participants