Thanks to visit codestin.com
Credit goes to github.com

Skip to content

adds isAttached getter to DraggableScrollableController #100269

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

Merged
merged 3 commits into from
Apr 14, 2022
Merged

adds isAttached getter to DraggableScrollableController #100269

merged 3 commits into from
Apr 14, 2022

Conversation

maheshj01
Copy link
Member

@maheshj01 maheshj01 commented Mar 17, 2022

This PR adds isAttached getter to DraggableScrollableController similar to ScrollController.hasClients

Fixes #99994

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

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 Mar 17, 2022
@maheshj01 maheshj01 changed the title adds isAttached getter to DraggableScrollController adds isAttached getter to DraggableScrollableController Mar 17, 2022
@HansMuller HansMuller requested a review from Piinks March 18, 2022 22:00
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.

Hey @maheshmnj! Can this instead use the hasClients property that already exists on ScrollController?

@Piinks
Copy link
Contributor

Piinks commented Mar 22, 2022

For more context, just because _attachedController is not null, does not mean there is an attached position that is safe to access. :)

@maheshj01
Copy link
Member Author

maheshj01 commented Mar 23, 2022

Can this instead use the hasClients property that already exists on ScrollController?

@Piinks, Oh Yes, We should use hasClients, But I was wondering to check for null too, Considering the added test

expect(controller.isAttached, false); ///  would throw Null check operator used on Null value

Instead of making isAttached nullable probably adding a null check would be right?

@goderbauer goderbauer requested a review from Piinks March 30, 2022 21:39
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 update!

/// If this is false, then members that interact with the [ScrollPosition],
/// such as [sizeToPixels], [size], [animateTo], and [jumpTo], must not be
/// called.
bool get isAttached => _attachedController != null && _attachedController!.hasClients;
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 update the _assertAttached function to use this getter now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@goderbauer
Copy link
Member

From triage: This probably needs to be rebased to make the failing check happy.

@goderbauer goderbauer requested a review from Piinks April 6, 2022 21:31
@maheshj01
Copy link
Member Author

Thanks for checking @goderbauer, I have rebased 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

Thank you!

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@goderbauer
Copy link
Member

Restarted the Google Testing check. Hopefully it will pass now.

@fluttergithubbot fluttergithubbot merged commit c815aae into flutter:master Apr 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[Proposal] Add "isAttached" property to DraggableScrollableController
4 participants