这是indexloc提供的服务,不要输入任何密码
Skip to content

Helpful assertion for isAlwaysShown error #58258

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
May 29, 2020

Conversation

justinmc
Copy link
Contributor

Description

When a scrollbar's isAlwaysShown is true, it must have a controller that's attached to a scrollview. Previously, an assertion deeper in the framework would get triggered if this wasn't the case, with an error message that's not so informative. This PR adds an assertion directly in the constructor with a more helpful error message.

Related Issues

Closes #53771

Tests

I added the following tests:

  • Check that an assertion is triggered when no controller at all.
  • Check that an assertion is triggered when the controller isn't attached to a scroll view.
  • The two above tests for material and cupertino.

@justinmc justinmc self-assigned this May 29, 2020
@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels May 29, 2020
@justinmc justinmc requested a review from LongCatIsLooong May 29, 2020 18:13
@justinmc
Copy link
Contributor Author

@onatcipli Does this look good to you? I wanted to make sure people understand they need to pass a controller to avoid confusion like in #53771 (comment).

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

LGTM!

}

expect(() async {
await tester.pumpWidget(viewWithScroll());
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this test pass prior to the change? Before this change the assert should still trigger at the end of the frame right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just tried it and it fails prior to the change (so does the corresponding material test).

It does still throw an error though, but I guess it's happening in the post frame callback and so it's not caught by this.

justinmc and others added 2 commits May 29, 2020 13:08
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
@fluttergithubbot fluttergithubbot merged commit 7d17c53 into flutter:master May 29, 2020
@justinmc justinmc deleted the is-always-shown-controller branch May 29, 2020 23:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scrollbar always shown property bugs when set to true
4 participants