Closes https://github.com/flutter/flutter/issues/160257.
~~This will sit on CI for a bit and give me a better idea of how much
work there is to do.~~ Done!
## IMPORTANT: Do **not** revert on 1-2 isolated post-submit failures.
While I've spent the last several weeks getting this passing all
presubmit tests, and some integration tests I suspected might be
affected, it is possible that there are 1-2 integration tests that will
fail as a result of landing this PR. I'll disable the flag
(`--no-explicit-package-dependencies`) if the failures look obvious
enough, otherwise I'll revert.
<!-- start_original_pr_link -->
Reverts: flutter/flutter#163711
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: victorsanni
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: This is closing the tree. See
https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20android_release_builds_exclude_dev_dependencies_test/889/overview
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: matanlurey
<!-- end_original_pr_author -->
<!-- start_reviewers -->
Reviewed By: {jonahwilliams}
<!-- end_reviewers -->
<!-- start_revert_body -->
This change reverts the following previous change:
Closes https://github.com/flutter/flutter/issues/163706.
Before this PR, the macOS workflow (or, others, but only macOS had a
test) would fail because it calls `refreshPluginsList` manually, and
sometimes it would be `determineDevDependencies: null` and sometimes
`determineDevDependencies: false`.
A value of `determineDevDependencies: null` was interpreted later on as
"find dev dependencies", which is not a safe operation. The only real
change in this PR is `bool determineDevDependencies = false`, so
omitting that parameter means we don't determine dev dependencies.
Added some tests, and opted-in an integration test that was failing.
<!-- end_revert_body -->
Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
<!-- start_original_pr_link -->
Reverts: flutter/flutter#140783
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: matanlurey
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: This broke presubmit (which was skipped using
`added this pull request to the merge queue 2 hours ago`).
See https://github.com/flutter/flutter/issues/162715. Adding to the
merge queue manually is _not_ safe currently.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: ueman
<!-- end_original_pr_author -->
<!-- start_reviewers -->
Reviewed By: {bkonyi}
<!-- end_reviewers -->
<!-- start_revert_body -->
This change reverts the following previous change:
This makes various Flutter version information available at runtime.
It's basically the same as executing `flutter --version`. This is
especially useful for tools like Crashlytics or Sentry (see for example
https://github.com/getsentry/sentry-dart/issues/416).
Usage example:
```dart
FlutterVersion.version; // 3.16.5
FlutterVersion.channel; // stable
FlutterVersion.gitUrl; // https://github.com/flutter/flutter.git
FlutterVersion.frameworkRevision; // 78666c8dc5
FlutterVersion.engineRevision; // 3f3e560236
FlutterVersion.dartVersion; // 3.2.3
```
This approach has prior art as seen in #134179.
Fixes https://github.com/flutter/flutter/issues/61814
<!-- *If you had to change anything in the [flutter/tests] repo, include
a link to the migration guide as per the [breaking change policy].* -->
## 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 [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [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].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
<!-- end_revert_body -->
Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
Closes https://github.com/flutter/flutter/issues/163706.
Before this PR, the macOS workflow (or, others, but only macOS had a
test) would fail because it calls `refreshPluginsList` manually, and
sometimes it would be `determineDevDependencies: null` and sometimes
`determineDevDependencies: false`.
A value of `determineDevDependencies: null` was interpreted later on as
"find dev dependencies", which is not a safe operation. The only real
change in this PR is `bool determineDevDependencies = false`, so
omitting that parameter means we don't determine dev dependencies.
Added some tests, and opted-in an integration test that was failing.
https://github.com/flutter/flutter/issues/163329
Tested locally to ensure pressing 'd' in a running `flutter run` session
detaches and leaves Chrome open. Hitting 'q' or stopping with a signal
both terminate Chrome as expected.
## 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 [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [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] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
---------
Co-authored-by: Nate Biggs <natebiggs@google.com>
If the Flutter SDK is updated we need to invalidate the widget preview
scaffold project to, at the very least, rebuild the precompiled
application. Similarly, if the root project's `pubspec.yaml` is updated,
the scaffold project's pubspec should be regenerated.
This change adds a `preview_manifest.json` to the scaffold project which
contains information related to:
- The manifest schema version
- The Dart SDK version the project was generated with
- The last known hash of the root project's pubspec.yaml
This information is used to determine whether or not the scaffold
project needs to be regenerated or the scaffold pubspec needs to be
updated to reflect changes to the root project's pubspec since the
previewer was last run.
Closes https://github.com/flutter/flutter/issues/162399.
Closes https://github.com/flutter/flutter/issues/163272.
`refreshPluginsList` is commonly called in iOS/macOS apps, more times
than you expect (and load bearing);
https://github.com/flutter/flutter/issues/157391.
With `--explicit-package-dependencies`, we no longer write (or compare)
the output of `.flutter-plugins`. The iOS/macOS workflows required `pod
install` output to be invalidated when plugins when change, but the
logic that was being used to see if plugins changed _only_ worked for
the `.flutter-plugins` file format.
In the original code:
```txt
# oldPluginsFileStringContent
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"/Users/matanl/Developer/flutter/packages/integration_test/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"ios_objc_cocoapods_plugin","path":"/var/folders/qw/qw_3qd1x4kz5w975jhdq4k58007b7h/T/swift_package_manager_enabled.XrEWXS/ios_objc_cocoapods_plugin/","native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"integration_test","path":"/Users/matanl/Developer/flutter/packages/integration_test/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"ios_objc_cocoapods_plugin","dependencies":[]}],"date_created":"2025-02-13 17:01:11.023097","version":"3.30.0-1.0.pre.163","swift_package_manager_enabled":{"ios":true,"macos":false}}
# pluginsMap
{ios: [{name: integration_test, path: /Users/matanl/Developer/flutter/packages/integration_test/, native_build: true, dependencies: [], dev_dependency: false}, {name: ios_objc_cocoapods_plugin, path: /var/folders/qw/qw_3qd1x4kz5w975jhdq4k58007b7h/T/swift_package_manager_enabled.XrEWXS/ios_objc_cocoapods_plugin/, native_build: true, dependencies: [], dev_dependency: false}], android: [{name: integration_test, path: /Users/matanl/Developer/flutter/packages/integration_test/, native_build: true, dependencies: [], dev_dependency: false}], macos: [], linux: [], windows: [], web: []}
```
As you can see, `pluginsChanged =
oldPluginsFileStringContent.contains(pluginsMap.toString());` was
_always_ `false`, but we never knew because we'd always just fall back
to using the `.flutter-plugins` content comparison (which always
worked).
I added a test as well.
This also appears to fix
https://github.com/flutter/flutter/issues/162399.
/cc @jmagman @jonahwilliams
The existing code assumed that DWDS needed to initialize some of the JS
state between adding all the scripts to queue and when they are loaded.
A closer examination of the existing AMD module format bootstrapper
shows that we already only initialize DWDS' JS state after all the
scripts are loaded. This is because it waits for the entrypoint to be
loaded before initializing that state, and the entrypoint is only loaded
after all its dependencies are loaded, which includes the SDK and
transitively every file in the app.
Since it's simpler and avoids the double-gating to call main, this
change moves that initialization to after all the scripts are loaded and
aligns with the AMD module bootstrapper.
## 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 [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] 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].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
`flutter widget-preview start --web` will cause the widget preview
scaffold to be run as a Flutter Web application using experimental hot
reload support. This will eventually be the default, with the desktop
environment being put behind a flag for use as a fallback under the
assumption that the desktop environment will be removed in the future.
- Adds better instructions for hot reload (if using the right flags),
hot restart, quitting, clearing, and more. These were already being
printed when using the VM, so this aligns with that.
- Adds an extra parameter for `CommandHelp` to `ResidentRunner` so
`ResidentWebRunner` can pass a version of it that uses its separate
logger and not `globals`. In order to support this, classes up the stack
also provide a `Terminal`, `Platform`, and `OutputPreferences`.
- Fixes up use of `globals` from an earlier change to implement hot
reload to use the logger instead. Same with `globals.platform`.
- Adds tests to check that only hot restart is printed when not using
the extra front-end flags, and both hot restart and hot reload is
printed when you are.
## 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 [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [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] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
I happened to run into this while chasing other bugs, and noticed
`.flutter-plugins-dependencies` is omitted.
I am guessing this is probably quite stale, but something something
[Chesterton's
fence](https://en.wiktionary.org/wiki/Chesterton%27s_fence), and added
tests.
- Delete code paths that handle screenshots for the HTML renderer
- Delete artifact enums for the HTML/AUTO renderers (and all their
usages).
- Remove HTML/AUTO renderers warnings.
- Delete the HTML/AUTO renderer enums (and all their usages).
- Delete tests for all the above.
`generateLocalizations` should fail (`flutter gen-l10n`) if `flutter:
generate:` does not exist.
The previous logic was faulty, because it was totally possible to
opt-out of synthetic packages (i.e. in a `l10n.yaml` file), but still
not be specifying `flutter: generate:`, which I _believe_ is supposed to
still be an error.
This came up in https://github.com/flutter/flutter/pull/160289 as
`flutter config --explicit-package-dependencies` is enabled by default,
as the error is no longer thrown. Made a few other small test
forward-fixes that otherwise would break with the switch (but are
expected) as well.
Closes https://github.com/flutter/flutter/issues/162846.
At HEAD, including before this PR, it was impossible to use, or pass-in,
an unsound null-safety mode, but we still had code checking for it, and
reported analytics (I think? Some of these are `package:usage` specific
which is defunct).
This PR eradicates the otherwise unused code.
Closes https://github.com/flutter/flutter/issues/162704.
/cc @loic-sharma.
I expect I'll have to update some iOS/macOS unit and possibly
integration tests due to this change, but wanted something concrete to
talk about during our 1:1. Feel free to leave comments or questions even
if this PR is in "draft".
Towards https://github.com/flutter/flutter/issues/162846.
Removes all of the unsound host artifacts, and then uses their name for
the sound artifacts.
That is, for something like `webPlatformDDCKernelDill`, this PR:
- Changes the web GN builders to only emit the sound SDK, without the
`-sound` suffixes
- Deletes `webPlatformDDCKernelDill` and all usages of it (implicitly
unsound, and unused).
- Renames `webPlatformDDCKernelSoundDill` to `webPlatformDDCKernelDill`.
No user impact expected, as there was no way to use the unsound
artifacts from the Flutter tool.
With this change, `flutter widget-preview start` will launch a working
widget preview environment that can render previews from a target
project.
Also fixes an issue where `--offline` wasn't being respected by some pub
operations.
Rather than ask users to pass the complicated and long string
`--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc`
we want a simpler flag to enable the new DDC module system/hot reload.
Technically this flag enables the new module system, not necessarily hot
reload directly. But we only expect people to use the flag to enable hot
reload so I've chosen the name based on that.
---------
Co-authored-by: Nate Biggs <natebiggs@google.com>
SkSL precompilation was only ever beneficial for iOS. For other
platforms, we recommended against it as Skia generated shaders per
target architecture which could be invalid on other devices. It is no
longer possible to use Skia on iOS.
Delete all Skia shader bundling logic.
Fixes https://github.com/flutter/flutter/issues/80091
On an internal chat, I asked:
> Is there a reason I don't understand why `flutter` should still
support "unsound" null-safety modes?
@jonahwilliams:
> I don't believe its possible to have non-null safe flutter code.
---
There is quite a bit of code and branches, so to keep the PRs
understandable/approachable, this first PR removes the ability to have
the `DevFS` implementations for the web SDK choose between sound and
unsound null safety, and removes the mapping accordingly.
The enums still exist, but can be cleaned up in a follow-up PR (you'd
want to rename to remove "sound" as well, ideally).
Powered by the new and amazing `unnecessary_ignore` lint.
We're not enabling this lint by default because being able to
temporarily use ignores that don't ignore anything is a powerful tool to
enable migrations. We should turn this lint on locally periodically,
though, and clean up all outdated ignores.
This also wires up the preview detector to trigger hot reloads when new
previews are detected or previews are removed.
Note: while this change results in lib/generated_preview.dart being
generated and updated, it's not currently referenced by lib/main.dart
and the preview environment will render a black screen.
---------
Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
https://github.com/flutter/flutter/issues/162567
- Uses the `bootstrapScript` field in `loadConfig` to run a script after
all scripts have loaded.
- This script just calls a callback that is set up beforehand and calls
main.
- Modifies the callback that calls `dartDevEmbedder.runMain` to wait
until both DWDS called main and all scripts have loaded.
- Unskips hot reload tests now that the race condition should no longer
exist.
## 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].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
recompile has been split into recompile and recompile-restart in the
frontend server so that DDC can distinguish between hot reload
recompiles and hot restart recompiles, and therefore emit rejection
errors only on hot reload.
https://github.com/dart-lang/webdev/issues/2516
## 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 [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [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] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
https://github.com/dart-lang/webdev/issues/2516
- Updates restart/reload code to accept a resetCompiler boolean to
disambiguate between whether this is a full restart and whether to reset
the resident compiler.
- Adds code to call reloadSources in DWDS and handle the response
(including any errors).
- Adds code to invoke reassemble.
- Adds code to emit a script that DWDS can later consume that contains
the changed sources and their associated libraries. This is used to hot
reload. The bootstrapper puts this in the global window. DWDS should be
updated to accept it in the provider itself. See
https://github.com/dart-lang/webdev/issues/2584.
- Adds code to parse module metadata from the frontend server. This is
identical to the implementation in DWDS % addressing type-related lints.
- Adds tests that run the existing hot reload tests but with web. Some
modifications are mode, including waiting for Flutter runs to finish
executing, and skipping a test that's not possible on the web.
Needs DWDS 24.3.4 to be published first and used before we can land.
## 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 [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [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] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.