Closes https://github.com/flutter/flutter/issues/169598 (which explains
the integration test failure).
Closes https://github.com/flutter/flutter/issues/169160.
Closes https://github.com/flutter/flutter/issues/165803.
This is the only diff from 5d013c73ba:
```diff
diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart
index 61583210e47..67731019a05 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/common.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart
@@ -308,10 +308,18 @@ class KernelSnapshot extends Target {
if (flavor == null) {
return;
}
- if (!dartDefines.any((String element) => element.startsWith(kAppFlavor))) {
- // If the flavor is not already in the dart defines, add it.
- dartDefines.add('$kAppFlavor=$flavor');
- }
+
+ // It is possible there is a flavor already in dartDefines, from another
+ // part of the build process, but this should take precedence as it happens
+ // last (xcodebuild execution).
+ //
+ // See https://github.com/flutter/flutter/issues/169598.
+
+ // If the flavor is already in the dart defines, remove it.
+ dartDefines.removeWhere((String define) => define.startsWith(kAppFlavor));
+
+ // Then, add it to the end.
+ dartDefines.add('$kAppFlavor=$flavor');
}
}
```
This enables breakpoint management for hot restart and hot reload.
--start-paused is passed by VS code.
Also fixes a small issue where we're not passing the isolate ID when hot
reloading. It doesn't matter what we pass as there's only one isolate,
but we should keep consistent and use the isolate ID that already
exists.
https://github.com/dart-lang/sdk/issues/60186
## 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.
Fixes#136109 P2
Related #148028 P1
Roadmap:
- [x] find why not working (described in #136109)
- [x] create new API with backward compatibility
(`--browser-dimension=393×852@3`)
- [x] fix edge cases
- [x] internal testing
- [x] add documentation (flutter drive -h)
This PR:
- Fixes Chrome bug from dart side
- Adds pixelRatio mobile emulation in web
- Adds new notation: 393,852 -> 393×852[@1]
- Leaves previous behavior as it was, so 393,852 will give wrong size
until Chrome will fix it. But you can use 393×852@1.
---------
Co-authored-by: Mouad Debbar <mdebbar@google.com>
<!-- start_original_pr_link -->
Reverts: flutter/flutter#169451
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: matanlurey
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Broke a number of post-submit tests
(ios_app_extension, packages_autoroller).
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: mosuem
<!-- end_original_pr_author -->
<!-- start_reviewers -->
Reviewed By: {matanlurey}
<!-- end_reviewers -->
<!-- start_revert_body -->
This change reverts the following previous change:
Reland after #169357.
Switch Flutter to use pub workspaces as a preparation to unpin selected
packages.
Assumptions:
1. No packages in this repository are published to pub.dev --> We can
use `any` dependencies in most local pubspecs, as the global constraint
defines the version. An exception are the packages used outside of this
repo with an `sdk` dependency, namely `flutter_localizations`,
`flutter_test`, and `flutter`.
2. The "universes" `{flutter_tools}` and `{flutter,
flutter_localizations, flutter_goldens}` can use different packages
versions, as they are not resolved together. --> We do not need to
upgrade them in sync, we can first do one "universe", then the other.
Based on these assumptions, we use
https://github.com/mosuem/pubspec_merger.dart to merge all packages in
the `flutter` universe into a top-level pub workspace.
The `flutter` and `flutter_tools` workspaces being separate also ensures
that changes to `flutter` will not inadvertently break `flutter_tools`,
with not-so-nice consequences for our users which would be unable to run
`flutter upgrade`.
There is a third "top-level" pubspec besides `./pubspec.yaml` and
`packages/flutter_tools/pubspec.yaml`, namely
`packages/flutter_tools/.../widget_preview_scaffold/pubspec.yaml`. This
is an artifact due to it living under `flutter_tools`, so it can't be
part of the `./pubspec.yaml` workspace. Moving it would be a larger
change, and out of the scope of this PR.
This required a rewrite of the update-packages tool, but the main
functionality stays the same, as well as the argument names, to ensure a
seamless transition.
## 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.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#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/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
<!-- end_revert_body -->
Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
Reland after #169357.
Switch Flutter to use pub workspaces as a preparation to unpin selected
packages.
Assumptions:
1. No packages in this repository are published to pub.dev --> We can
use `any` dependencies in most local pubspecs, as the global constraint
defines the version. An exception are the packages used outside of this
repo with an `sdk` dependency, namely `flutter_localizations`,
`flutter_test`, and `flutter`.
2. The "universes" `{flutter_tools}` and `{flutter,
flutter_localizations, flutter_goldens}` can use different packages
versions, as they are not resolved together. --> We do not need to
upgrade them in sync, we can first do one "universe", then the other.
Based on these assumptions, we use
https://github.com/mosuem/pubspec_merger.dart to merge all packages in
the `flutter` universe into a top-level pub workspace.
The `flutter` and `flutter_tools` workspaces being separate also ensures
that changes to `flutter` will not inadvertently break `flutter_tools`,
with not-so-nice consequences for our users which would be unable to run
`flutter upgrade`.
There is a third "top-level" pubspec besides `./pubspec.yaml` and
`packages/flutter_tools/pubspec.yaml`, namely
`packages/flutter_tools/.../widget_preview_scaffold/pubspec.yaml`. This
is an artifact due to it living under `flutter_tools`, so it can't be
part of the `./pubspec.yaml` workspace. Moving it would be a larger
change, and out of the scope of this PR.
This required a rewrite of the update-packages tool, but the main
functionality stays the same, as well as the argument names, to ensure a
seamless transition.
## 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.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#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/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This change removes references to Observatory, including:
- Deprecated flags
- Deprecated embedder APIs
- Outdated documentation
- Documentation instances where "VM service" should have been used
- Incorrectly named tests / directories
As a part of this change, `--serve-observatory` is no longer a valid
flag.
Observatory is still available for now via the `_serveObservatory` RPC,
but will be removed in a follow up PR once we've prepared for breakages
in G3.
Work towards https://github.com/dart-lang/sdk/issues/50233
FYI @a-siva
Switch Flutter to use pub workspaces as a preparation to unpin selected
packages.
Assumptions:
1. No packages in this repository are published to pub.dev --> We can
use `any` dependencies in most local pubspecs, as the global constraint
defines the version. An exception are the packages used outside of this
repo with an `sdk` dependency, namely `flutter_localizations`,
`flutter_test`, and `flutter`.
2. The "universes" `{flutter_tools}` and `{flutter,
flutter_localizations, flutter_goldens}` can use different packages
versions, as they are not resolved together. --> We do not need to
upgrade them in sync, we can first do one "universe", then the other.
Based on these assumptions, we use
https://github.com/mosuem/pubspec_merger.dart to merge all packages in
the `flutter` universe into a top-level pub workspace.
The `flutter` and `flutter_tools` workspaces being separate also ensures
that changes to `flutter` will not inadvertently break `flutter_tools`,
with not-so-nice consequences for our users which would be unable to run
`flutter upgrade`.
There is a third "top-level" pubspec besides `./pubspec.yaml` and
`packages/flutter_tools/pubspec.yaml`, namely
`packages/flutter_tools/.../widget_preview_scaffold/pubspec.yaml`. This
is an artifact due to it living under `flutter_tools`, so it can't be
part of the `./pubspec.yaml` workspace. Moving it would be a larger
change, and out of the scope of this PR.
This required a rewrite of the update-packages tool, but the main
functionality stays the same, as well as the argument names, to ensure a
seamless transition.
## 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.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#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/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This feature landed opt-in in 3.29 and opt-out in 3.32:
https://docs.flutter.dev/release/breaking-changes/flutter-generate-i10n-source
In this PR, we remove the ability to use `flutter config
--no-enable-explicit-package-dependencies`, and remove all places that
opt-in to the flag (which are currently NOPs). Follow-up PRs will
refactor tests relying on the older behavior, and then finally remove
`package:flutter_gen` and the `.flutter-plugins` (legacy format) file
guarded by this flag.
Essentially this PR is
`s/getSyntheticGeneratedFileContent/getGeneratedFileContent` for a
particular test suite.
Made one non-test change (`bool useSyntheticPackage = false`) that
in-practice should be a NOP, mostly so I could catch (and remove) cases
where the default argument was already being passed-in. A follow-up PR
will continue to remove the synthetic package support features (and
refactor or remove tests where necessary).
This flag has been enabled by default for quite some time in `master`,
and in the current `stable`.
This is the first of many PRs to get rid of the flag and the deprecated
code it is guarding.
This PR introduces two new widgets:
- `DisableWidgetInspectorScope`, which hides its children from the
widget inspector
- `EnableWidgetInspectorScope`, which makes its children available to
the widget inspector
These widgets are used to inform the `WidgetInspectorService`'s
`InspectorSerializationDelegate` when it should be omitting
`DiagnosticableNodes` from the response when building the root widget
tree for the inspector.
This functionality is meant to be used by developer tooling and packages
that want to prevent unnecessary implementation details from polluting
the inspector and possibly confusing end users.
This change also includes some minor updates to the Widget Preview
scaffolding template to hide the scaffold's implementation details and
only show details for the previews defined by the user.
Part of https://github.com/flutter/flutter/issues/166423
**Widget Previewer Demo**
<img width="1606" alt="image"
src="https://github.com/user-attachments/assets/eb23160e-01c5-413f-b1d2-97985ced9ef9"
/>
Fixes a couple issues:
- Passes --web-experimental-hot-reload when library bundle format is
enabled.
- Passes chrome id only if chrome is enabled.
- Makes sure common code is run with VM and chrome.
## 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].
- [ ] 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.
This change makes the detection of `@Preview(...)` annotations more
robust by converting the analyzer AST directly to generated code rather
than simply copying and pasting the original source. This allows for
proper handling of the following cases WRT import prefixing:
- The use of `const`
- String interpolation
- Other uses of constant variables in non-trivial contexts
- Etc.
This PR addresses
[flutter/flutter#167102](https://github.com/flutter/flutter/issues/167102),
where debugging support code was not being properly injected when
running on Edge `flutter run -d edge`. The issue was due to missing
conditions in the injection logic that prevented the debugger service
from initializing correctly in this environment.
This change ensures that debugging support is consistently injected when
connected devices are present and the user has selected one of them.
fix https://github.com/flutter/flutter/issues/167102.
The link hooks (`hook/link.dart`) in Flutter have no access to the
resource identifier experiment for tree-shaking yet. That means we can
start running hooks earlier in the flutter build.
When we do get around to adding tree-shaking information, we should only
have a dependency on `KernelSnapshot` for AOT builds in which the Dart
tree-shaker runs. Likely achieved by splitting the `DartBuildForNative`
into two targets, one for Debug and one for Release. (Note, the names
for these targets are somewhat weird, so we should address that in
another PR as well. It should probably be called `RunDartHooks` or
something.)
I don't expect this PR to have any performance effect for fast hooks.
Other targets already run concurrently with this target:
```
$ flutter build -d macos --verbose
[ ] [ +278 ms] compile_macos_framework: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /Users/dacoharkes/flt/flutter/examples/hello_world/.dart_tool/flutter_build/ce2ba8b9e7204bce6beba11f20d6df36/app.dill,/Users/dacoharkes/flt/flutter/packages/flutter_tools/lib/src/build_system/targets/macos.dart,/Users/dacoharkes/flt/flutter/bin/cache/engine.stamp}
[...]
[ ] [ ] dart_build: Starting due to {}
[ ] [ +20 ms] No packages with native assets. Skipping native assets compilation.
[ ] [ +1 ms] dart_build: Complete
[ ] [ +1 ms] install_code_assets: Starting due to {}
[ ] [ +1 ms] Writing native assets json to file:///Users/dacoharkes/flt/flutter/examples/hello_world/.dart_tool/flutter_build/ce2ba8b9e7204bce6beba11f20d6df36/native_assets.json.
[ ] [ +1 ms] Writing /Users/dacoharkes/flt/flutter/examples/hello_world/.dart_tool/flutter_build/ce2ba8b9e7204bce6beba11f20d6df36/native_assets.json done.
[ ] [ ] install_code_assets: Complete
[ ] [+1376 ms] Building App.framework for x86_64...
[...]
[ ] [ +41 ms] compile_macos_framework: Complete
```
However, this PR makes the hooks already run concurrently with kernel
compilation, which always takes quite a while.
```
[ ] [ +2 ms] kernel_snapshot_program: Starting due to {}
[...]
[ ] [+2515 ms] release_unpack_macos: Complete
[ ] [+2425 ms] kernel_snapshot_program: Complete
```
This means that if the hooks do actual work, and enough cores on the
host are available for Dart compilation and hook execution, the result
will be quicker than before.
### Context
* https://github.com/dart-lang/native/issues/2236
### Testing
Existing native assets integration tests
### Benchmarks
Currently _not_ benchmarked. This will be benchmarked by the `flutter
build` and flutter-time-to-first-frame benchmarks once the experiment
flag is removed.
This worked before accidentally, presumably by using stale
source maps. Now that invocations in closures are transformed
by the compiler, the stale source maps are now invalid, leading
to timeouts in tests when running against the latest Dart SDK.
Skip this test instead until breakpoints work.
## 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].
- [ ] 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.
- [ ] All existing and new tests are passing.
This PR makes the following improvements to web hot reload support and
related tests:
- The `--start-paused` flag is now silently added when running with `-d
web-server --web-experimental-hot-reload` if it is not already present.
- Refactored test infrastructure to allow specifying the device
parameter (e.g., `'chrome'`, `'web-server'`) when running integration
tests.
- Added a new `web_run_web_server_test` to run flows on the web-server
device.
- Updated existing tests to explicitly pass the correct device parameter
where needed.
- We are currently not able to test hot reload on the web-server device
as this is not yet supported.
Fixes https://github.com/dart-lang/sdk/issues/60289