Skip to content

Conversation

@AlexV525
Copy link
Member

@AlexV525 AlexV525 commented Oct 27, 2022

Consist messages when throwing from asset bundles.

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 the framework flutter/packages/flutter repository. See also f: labels. label Oct 27, 2022
@AlexV525 AlexV525 marked this pull request as ready for review October 27, 2022 09:01
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Hixie
Copy link
Contributor

Hixie commented Oct 27, 2022

We should add a test for this, just for completeness. Maybe while we're at it we could add more detail? Not sure if there's any more detail to add though.

@AlexV525
Copy link
Member Author

AlexV525 commented Oct 28, 2022

Wow I can't even find proper tests with PlatformAssetBundle, seems like a long working well component but no tests were added to it.

/// isolate to avoid jank on the main thread.
Future<String> loadString(String key, { bool cache = true }) async {
final ByteData data = await load(key);
if (data == null) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This should be removed. But the analyzer doesn't report with an unnecessary null check.

@AlexV525 AlexV525 marked this pull request as draft October 28, 2022 04:43
@AlexV525 AlexV525 changed the title Remove redundant . when throwing exceptions in asset bundle Improve exceptions thrown by asset bundle Oct 28, 2022
@AlexV525 AlexV525 marked this pull request as ready for review October 29, 2022 05:42
@AlexV525 AlexV525 requested review from Hixie and dnfield October 29, 2022 05:42
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #114139 at sha cd439c7

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Oct 29, 2022
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/39998

test('Throws expected exceptions when loading not exists asset', () async {
TestWidgetsFlutterBinding.ensureInitialized();
Copy link
Member Author

Choose a reason for hiding this comment

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

One strange thing I found during tests is if we call the ensureInitialized in this test file, the "NetworkAssetBundle control test" will fail because the request returns 400 instead of 404.

Copy link
Contributor

Choose a reason for hiding this comment

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

the widget tester overrides HTTP calls to always return 400.

Copy link
Member Author

Choose a reason for hiding this comment

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

the widget tester overrides HTTP calls to always return 400.

TIL.

Copy link
Member Author

Choose a reason for hiding this comment

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

Eventually I update the test to use 400 instead.

/// isolate to avoid jank on the main thread.
Future<String> loadString(String key, { bool cache = true }) async {
final ByteData data = await load(key);
if (data == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want to keep this here?

Copy link
Member Author

Choose a reason for hiding this comment

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

You see, the data here is not nullable, so it should be a unnecessary check IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I'm also wondering why the analyzer doesn't report about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh interesting, ok. Maybe because of unsound null safety?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll take another look to see if there are any issues with the linter rule.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #114139 at sha 337cb3b

@AlexV525 AlexV525 closed this Oct 30, 2022
@AlexV525 AlexV525 deleted the remove-dot-asset-bundle-exception branch December 10, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants