-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[wip] Flutter JS Bootstrap RFC #95379
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
Conversation
packages/flutter_web_plugins/lib/src/loader/flutter_loader.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/app_shared/web/flutter.js.tmpl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be fully static, and not generated via a template at flutter create time, but injected automatically by flutter when doing flutter build or flutter run. That way, end users won't feel the temptation of touching it :)
packages/flutter_tools/templates/app_shared/web/index.html.tmpl
Outdated
Show resolved
Hide resolved
|
Does the refactoring of the initialisation process in any way speed up the initial load times? |
|
Gold has detected about 1 new digest(s) on patchset 2. |
|
Gold has detected about 6 new digest(s) on patchset 2. |
|
We moved a lot of the code that was supposed to live in |
This PR is now out of date
Old description
This is a first attempt at yielding full control to the programmer over the initialization of a Flutter Web app.
Currently, Flutter Web apps start as soon as possible, and take over the whole screen. With this change, the startup of an App can be split in three stages (four, if we count the cleanup stage too):
To achieve this, some JS-interop and Promise-wrangling is needed. The new workflow is as follows:
_flutter.loader.loadMainDartJs_flutter.loader.didLoadMainDartJscallback. (This callback must be in a known location, because the first time Flutter calls JS, it needs to do so from a known place.)_flutter.loaderhas been used in JS, and sets up aFlutterLoaderobject that controls de lifecycle of the app.FlutterLoadercallsdidLoadMainDartJsin JS, with an instance of anEngineInitializer.loadMainDartJsin step 1.The new API above allows users to write their own (informative) splash screens, for example:
Backwards compatibility
This will be backwards compatible with old versions of index.html, but testing that hasn't been a priority of this first PoC.
Testing
No tests yet, but I've tried to minimize the amount of code living in "untestable" parts of the app (template files, and build scripts), and add as much as possible into flutter_web_plugins, where it's somewhat testable.
(Tests are probably failing now)
This is a WIP/RFC/Draft PR, so for now, there's no issues/checklist.
Manual testing
Clone this branch into your flutter/flutter fork, and ensure that your
flutterbinary is the one coming from your Github checkout.With the new version of flutter on your box, you'll be able to create a new app normally by using
flutter create. That should come with the new flutter.js and index.html templates.In order to get the see any changes you make in your test app that you just created, you'll need to add this to its pubspec.yaml:
And then be pretty nuclear with rebuilding your flutter tool. In my case, I've ended up using:
To ensure that changes in every type of file (dependency, template, application...) are applied at once. YMMV here.