This PR attempts to improve clarity of androids section of `flutter
doctor -v` output by providing explicit information about which JDK is
being used and how to configure a different one if needed.
### Before
```console
• Java binary at: /Users/user/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents/jbr/Contents/Home/bin/java
```
### After
1. When JDK is from Android Studio:
```console
• Java binary at: /Users/users/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with latest Android Studio installation
To manually set a custom JDK path, use: `flutter config --jdk-dir="path/to/jdk"`
```
2. When JDK is from JAVA_HOME env variable:
```console
• Java binary at: /Users/user/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents/jbr/Contents/Home/bin/java
This JDK is specified by JAVA_HOME environment variable
To manually set a custom JDK path, use: `flutter config --jdk-dir="path/to/jdk"`
```
3. When path to JDK is set in flutter config:
```console
• Java binary at: /Users/user/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents/jbr/Contents/Home/bin/java
This JDK was found in system PATH
To change current JDK, run: `flutter config --jdk-dir="path/to/jdk"`
```
4. When java binary is found in PATH (as fallback)
```console
• Java binary at: /Users/user/Applications/Android Studio Ladybug Feature Drop 2024.2.2 Canary 2.app/Contents/jbr/Contents/Home/bin/java
This JDK is specified in Flutter configuration
To manually set a custom JDK path, use: `flutter config --jdk-dir="path/to/jdk"`
```
### Motivation
I think it's described in
https://github.com/flutter/flutter/issues/153156#issuecomment-2336814991.
TLDR; many developers struggle with Java-related issues and more verbose
doctor's output will (presumably) improve DX in that part.
fixes#153156
## 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
---------
Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
Killing the flutter_tools parent process may leak child processes
spawned by the tools.
Also wait for the message indicating that DevTools has started before
stopping flutter_tools. If DevTools has not fully launched, then there
may be a race between DevTools startup and flutter_tools shutdown.
Fixes https://github.com/flutter/flutter/issues/159154
Closes https://github.com/flutter/flutter/issues/66006.
From what I can tell in the multi-view effort a variation of
https://github.com/flutter/flutter/pull/88609 already landed, meaning
that the current device-pixel-ratio is being used (as the tests in
#88609 are now passing), and I believe that means we can remove the
override/hack.
Will rely on "Google Testing" to run a TGP internally, or do so myself
if necessary.
Speculative fix for https://github.com/flutter/flutter/issues/157640.
A few observations:
- I was a bit paranoid about indented files meaning something was parsed
incorrectly
- I removed `android.enableR8=true` (not used elsewhere)
- I removed `android.experimental.enableNewResourceShrinker=true` (not
used elsewhere)
- I matched the rest of the `jvmargs` used in the standard template file
... let's hope this does good things?
Fixes https://github.com/flutter/devtools/issues/8155
Previously after enabling Widget Selection mode from DevTools and
selecting a widget to inspect, a user would then have to click the
on-device "Select widget" button before being able to select another
widget. This was very confusing to users; we got multiple comments on
our latest DevTools Survey that widget selection mode only worked the
first time and was broken on subsequent selections.
Now, once "Select widget mode" is enabled from DevTools, any subsequent
click is treated as a selection until the user exits from select widget
mode either via DevTools or via the Exit Selection mode button.
The user can re-position the Exit Selection button to either the left or
the right of their device (this way they can select a widget beneath
it).

Note: Previously this button was behind any widget selection overlays.
This PR also updates the order of the `Stack` so that exit selection
button is on top.
Enables the Scribe feature, or Android stylus handwriting text input.

This PR only implements basic handwriting input. Other features will be
done in subsequent PRs:
* https://github.com/flutter/flutter/issues/155948
* https://github.com/flutter/flutter/issues/156018
I created and fixed issue about stylus hovering while working on this:
https://github.com/flutter/flutter/issues/148810
Original PR for iOS Scribble, the iOS version of this feature:
https://github.com/flutter/flutter/pull/75472
FYI @fbcouch
~~Depends on https://github.com/flutter/engine/pull/52943~~ (merged).
Fixes https://github.com/flutter/flutter/issues/115607
<details>
<summary>Example code I'm using to test this feature (but any TextField
works)</summary>
```dart
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final FocusNode _focusNode1 = FocusNode();
final FocusNode _focusNode2 = FocusNode();
final FocusNode _focusNode3 = FocusNode();
final TextEditingController _controller3 = TextEditingController(
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Scribe demo'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 74.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
focusNode: _focusNode1,
autofocus: false,
),
TextField(
focusNode: _focusNode2,
),
TextField(
focusNode: _focusNode3,
minLines: 4,
maxLines: 4,
controller: _controller3,
),
TextButton(
onPressed: () {
_focusNode1.unfocus();
_focusNode2.unfocus();
_focusNode3.unfocus();
},
child: const Text('Unfocus'),
),
TextButton(
onPressed: () {
_focusNode1.requestFocus();
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
SystemChannels.textInput.invokeMethod('TextInput.hide');
});
},
child: const Text('Focus 1'),
),
],
),
),
),
);
}
}
```
</details>
---------
Co-authored-by: Nate Wilson <nate.w5687@gmail.com>
See https://github.com/flutter/flutter/issues/159154.
See https://github.com/flutter/flutter/pull/159169.
Before this PR, it appeared we were accidentally leaking (keeping
active) `flutter_tester` instances (or any test device) after `flutter
run` completion, even if the runner was not explicitly detached. I
_think_ this is a bug, but I'll check with the tools team and possibly
@jonahwilliams before finalizing this.
/cc @jason-simmons
---------
Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
Closes https://github.com/flutter/flutter/issues/158560.
I believe but am not sure as of
https://github.com/flutter/flutter/pull/159170 merging, many process
flakes that were consuming memory and in turn, making Gradle
particularly sensitive to timing out or being killing by the OS for
low-memory, have been rectified.
It is possible there are additional problems, but they aren't visible at
the moment.
I'd like to re-enable these and keep tracking their stability.
*I found that enableFeedback can be set to null, but in actual use,
setting it to null has no effect and is overwritten by true. I think
this is an issue.*
```dart
class InkWell extends InkResponse {
const InkWell({
super.key,
super.child,
super.onTap,
super.onDoubleTap,
super.onLongPress,
super.onTapDown,
super.onTapUp,
super.onTapCancel,
super.onSecondaryTap,
super.onSecondaryTapUp,
super.onSecondaryTapDown,
super.onSecondaryTapCancel,
super.onHighlightChanged,
super.onHover,
super.mouseCursor,
super.focusColor,
super.hoverColor,
super.highlightColor,
super.overlayColor,
super.splashColor,
super.splashFactory,
super.radius,
super.borderRadius,
super.customBorder,
bool? enableFeedback = true,
super.excludeFromSemantics,
super.focusNode,
super.canRequestFocus,
super.onFocusChange,
super.autofocus,
super.statesController,
super.hoverDuration,
}) : super(
containedInkWell: true,
highlightShape: BoxShape.rectangle,
enableFeedback: enableFeedback ?? true,
);
}
```
Call Error
```dart
InkWell(
enableFeedback: null,
)
```
The dart-lang/native repository contains a `Target` class that is almost
not needed anymore. The remaining uses are mainly due to kernel asset
mapping (which we may be able to remove in the future).
This PR removes usages of that `Target` (in favor of `Architecture`)
class in most places in flutter tools.
This makes the code also cleaner because we no longer have an implicit
assumption that
a `List<Target>` all belong to the same operating system.
Towards https://github.com/flutter/flutter/issues/51421.
```sh
flutter_tools % dart test test/integration.shard/break_on_framework_exceptions_test.dart
02:38 +29: All tests passed!
54692 ttys003 0:00.02 /opt/homebrew/bin/zsh -il
```
Requires https://github.com/flutter/flutter/pull/159115 for the process
cleanup to work properly, but this is safe to land as-is, otherwise we
still accumulate `flutter` processes over and over as each test case
runs which is not WAI.
Closes https://github.com/flutter/flutter/issues/20949.
Signals (such as SIGTERM or SIGKILL) end up flowing through
`exitWithHooks`, which in turn, after running hooks, call `exit().` That
means, as a result, any `try { } finally { }` guarded execution may
_not_ run, which happens to also be how `flutter_tester` instances are
cleaned up if they have not terminated.
This PR adds in-progress `flutter_tester` runs (or any platform
`flutter_platform` supports) to the shutdown hooks, guaranteeing that
the finalizers (which in turn, kill the process) are _always_ executed
as long as either the test completes, _or_ `exitWithHooks` is called.
The existing integration tests (`integration.shard/test_test.dart`)
still pass as well.
## Description
This PR fixes `InkWell` overlay colors resolution.
The `InkWell` overlay color is resolved when the `InkWell` is either
focused, hovered , and/or pressed.
This resolution happens at two places:
- first when the highlight is created.
- then on each build, using the inner function named
`getHighlightColorForType`.
This second resolution should be aware of other current states (such as
selected) as it might impact the color resolution.
For instance, several Material styles have colors resolution define
similarly to:
dc44547d0d/packages/flutter/lib/src/material/date_picker_theme.dart (L982-L1006)
## Related Issue
Fixes [InkWell overlay colors aren't applied on MaterialState.selected
state](https://github.com/flutter/flutter/issues/159063)
First step for [Date picker overlay colors aren't applied on
MaterialState.selected state](Date picker overlay colors aren't applied
on MaterialState.selected state).
## Tests
Adds 3 tests.
## Description
This adds a `scrollBehavior` attribute to `SelectableText` so that the
scrolling can be controlled more directly.
I added this specifically because it's not possible to turn off the
scrollbar on a selectable text, even if you set the scroll physics to be
`NeverScrollableScrollPhysics`. We had a UI where we needed to have a
clipped, multi-line selectable text field, but have it not be scrollable
unless it was expanded in size, and it wasn't possible to hide the
scrollbar, but still wanted it to be selectable.
## Tests
- Added a test that makes sure that the scroll behavior makes it down to
the `Scrollable` in the `EditableText`.
It's possible that the tool can be in the process of shutting down,
which could result in the temp directory being deleted after the
shutdown hooks run before we check if `output` exists. If this happens,
we shouldn't crash but just carry on as if no devices were found as the
tool will exit on its own.
Fixes https://github.com/flutter/flutter/issues/141892
---------
Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
Towards https://github.com/flutter/flutter/issues/159000 as part of
debugging issues such as
https://github.com/flutter/flutter/issues/158560.
On a `bringup: true` shard, run a number of `flutter build apk` tests in
succession to try and routinely trigger timeouts and crashes, so we can
test other hypotheses on how to fix this problem (i.e. potentially
around increasing memory, changing daemon configuration, aggressively
killing processes, etc).
## Description
This makes the `focusNode` for `SelectableRegion` optional so that:
- Users of the widget are no longer required to use `SelectableRegion`
from within a `StatefulWidget`
- They aren't likely to forget to dispose of a node they didn't supply.
- Simpler to use, and the node is not used very often anyhow.
Also made the `SelectableRegion` sample actually use `SelectableRegion`.
## Tests
- Modified all the `SelectableRegion` tests to remove 3 identical lines
of boilerplate from each (except 2, which actually used their focus
nodes).
Currently the `NativeAsset` target in flutter tools is responsible for
two things:
* performing the dart build (in the app as well as all transitive pub
dependencies)
* taking output (shared libraries) from this build and copying them
around
This intermingling of responsibilities leads to more complex code and
potentially unnecessary work: If the source code changed (e.g. `.c`
files change) we have to run the dart build again. But doing so may
result in the same shared libraries (e.g. adding comments to the `.c`
code). Currently we're going to copy the shared libraries despite them
having not changed, which then may cause upstream things to be dirtied
(if it's based on timestamp of files) and re-built.
Instead this PR splits this `NativeAsset` into the two orthogonal pieces
* `DartBuild` target that is responsible for the dart build
* `InstallCodeAssets` that is responsible for copying shared libraries
to the right place and producing a `native_assets.yaml`.
This decoupling is also preparation for a future where a dart build can
produce other kinds of assets (e.g. data assets) and is used in the web
build as well. (The web build would use `DartBuild` but not
`InstalCodeAssets`).
After the dart build is done, the flutter tool has to bundle the
produced shared libraries, which it does that by copying them around.
Though the code assumed that all code assets are shared libraries to be
bundled, whereas in fact one can have code assets without any actual
code (ones that are installed on the target system already or artificial
code assets whose symbols get resolved from executable / process).
=> Using non-bundled code assets currently results in null pointer
exceptions and/or cast errors.
=> We update the copy code to only operate on code assets that have a
shared library to bundle.
We also update the copy routines by removing copy&past'ed - but slightly
different - printing code into the shared caller function.
In release builds linking of native assets is enabled. The build step is
only a temprary step, it's output is given to the link step which then
returns all final assets (effectively a map-reduce system). Assets that
aren't sent to a specific linker could be conceptually viewed as sent to
a linker that will emit it's input as-is.
=> The code currently took output of build & link step and therefore
accumulated assets that aren't explicitly sent to a linker twice.
=> This led to performing work twice for those (e.g. copying them twice)
This PR changes this such that if linking mode is enabled, we only rely
on the output of the link phase.
That in return means many tests that mock the native asset builds need
to be updated to mock the output of the link phase.