Skip to content
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

Fix incorrect assetBase documentation #11342

Closed
wants to merge 2 commits into from
Closed

Conversation

dowski
Copy link

@dowski dowski commented Oct 30, 2024

Description of what this PR is changing or adding, and why: Fixing a documentation bug.

Issues fixed by this PR (if any): #11341

PRs or commits this PR depends on (if any): N/A

Presubmit checklist

  • This PR is marked as draft with an explanation if not meant to land until a future stable release.
  • This PR doesn’t contain automatically generated corrections (Grammarly or similar).
  • This PR follows the Google Developer Documentation Style Guidelines — for example, it doesn’t use i.e. or e.g., and it avoids I and we (first person).
  • This PR uses semantic line breaks of 80 characters or fewer.

@dowski dowski requested review from sfshaza2, parlough and a team as code owners October 30, 2024 02:44
Copy link

google-cla bot commented Oct 30, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

lgtm

@sfshaza2
Copy link
Contributor

/gcbrun

@dowski
Copy link
Author

dowski commented Oct 31, 2024

So actually, I just double-checked my code and the doc change I made is not right. assetBase is actually an argument to engine intializer initializeEngine, not _flutter.loader.load().

@dowski
Copy link
Author

dowski commented Oct 31, 2024

The assetBase arg to initializeEngine is still documented, although the whole page that contains those docs say they are for legacy versions of Flutter.

https://docs.flutter.dev/platform-integration/web/initialization-legacy#initializing-the-engine

There's not really a good home for it on this page as it stands. My overall goal is to correct the mistake noted in flutter#11341, and maybe a larger re-work of the docs can be done by someone else (maybe in flutter#11320?).
@dowski
Copy link
Author

dowski commented Nov 1, 2024

Okay, I tweaked this PR to make it correct. It does feel like some restructuring of the docs is in order (assetBase is nicely documented on the "legacy" initialization page). Maybe that's part of the goal of #11320?

@dowski dowski requested a review from sfshaza2 November 1, 2024 17:02
@sfshaza2
Copy link
Contributor

sfshaza2 commented Nov 1, 2024

/gcbrun

@flutter-website-bot
Copy link
Collaborator

Visit the preview URL for this PR (updated for commit 3c2842e):

https://flutter-docs-prod--pr11342-patch-1-i3il2yy4.web.app

@dowski
Copy link
Author

dowski commented Nov 2, 2024

Sigh

I think this is doc change is still wrong, after reading more of the code.

As long as you don't supply a custom onEntryPointLoaded callback, you can supply assetBase in the config. It will get passed to initializeEngine here.

If you do supply a custom onEntryPointLoaded callback, you must manually pass it the config that was passed to _flutter.loader.load() (or instead of passing it there? -- I'm not clear on that).


Maybe the real fix here is to document that the initializeEngine call should receive the same config that _flutter.loader.load() receives? What do you all think?

@dowski dowski mentioned this pull request Nov 2, 2024
1 task
@dowski
Copy link
Author

dowski commented Nov 2, 2024

I'm going to close this and come back w/ a fresh PR focused on what I discovered above.

@dowski dowski closed this Nov 2, 2024
@johnpryan
Copy link
Contributor

Thanks for sharing your findings @dowski! I haven't validated this, but am I understanding correctly that when you configureassetBase influtter.loader.load(), you need to also provide it to the onEntrypointLoaded callback? cc: @ditman @eyebrowsoffire

@dowski
Copy link
Author

dowski commented Nov 6, 2024

Hey @johnpryan - you're welcome.

It's more like if you pass an onEntryPointLoaded callback, assetBase gets ignored unless you manually pass it to the initializer. initializeEngine call in the callback.

I wound up filing a new focused bug that includes sample code:

flutter/flutter#158041

I didn't file it here in the website repo as I'm not sure it's strictly a documentation issue. The API feels plain hard to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants