packages icon indicating copy to clipboard operation
packages copied to clipboard

[image_picker] Adopt code excerpts in README

Open mike-v2 opened this issue 1 year ago • 5 comments

Improves image_picker_for_web README example and updates it to use code excerpts.

Part of flutter/flutter#102679

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • [x] I signed the CLA.
  • [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • [x] I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I added new tests to check the change I am making, or this PR is test-exempt.
  • [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

mike-v2 avatar Nov 30 '23 01:11 mike-v2

  • Tweaked the README code a tiny bit to make it more testable.
  • Added a small image (from flutter_image/example/assets) in order to test creating an Image widget from an XFile's path.

mike-v2 avatar Nov 30 '23 01:11 mike-v2

await XFile.readAsBytes() seems to be causing an issue on web. It's returning a valid Uint8List but for some reason it causes the test to stall indefinitely once it reaches the next await or the end of the test.

mike-v2 avatar Nov 30 '23 05:11 mike-v2

Even after creating a blob instead of loading an asset, I'm still having the same issue as before with XFile.readAsBytes(). I can get the test to pass without errors if I replace image = Image.memory(await pickedFile.readAsBytes()); with this: final Uint8List bytes = Uint8List.fromList(<int>[0, 1, 2, 3, 4, 5]); image = Image.memory(bytes);

I'm wondering if it's related to this issue? It's also very possible I'm making a dumb mistake!

mike-v2 avatar Jan 09 '24 20:01 mike-v2

@ditman Any thoughts on how to structure this test?

stuartmorgan-g avatar Jan 30 '24 20:01 stuartmorgan-g

@ditman Ping on the test question above.

stuartmorgan-g avatar Mar 05 '24 20:03 stuartmorgan-g

Looking!

ditman avatar Apr 12 '24 20:04 ditman

I moved the test to integration_test and added the missing IntegrationTestWidgetsFlutterBinding.ensureInitialized()... I also did other changes (to ensure that the PNG image is a valid one), but I'm not sure if those were needed. Now the tests run and pass!

@stuartmorgan if you're happy with the new contents of the README, I think this could land.

ditman avatar Apr 12 '24 23:04 ditman

auto label is removed for flutter/packages/5523, due to - The status or check suite Linux_android android_platform_tests_shard_3 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

auto-submit[bot] avatar Apr 15 '24 15:04 auto-submit[bot]

The presubmit failure is OOB breakage I just landed a fix for; once that is published I'll re-run.

stuartmorgan-g avatar Apr 15 '24 16:04 stuartmorgan-g

auto label is removed for flutter/packages/5523, due to - The status or check suite Linux_android android_platform_tests_shard_3 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

auto-submit[bot] avatar Apr 15 '24 18:04 auto-submit[bot]