-
Notifications
You must be signed in to change notification settings - Fork 29k
[flutter_tools] Ensure flutter daemon clients can detect preview device #140112
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
[flutter_tools] Ensure flutter daemon clients can detect preview device #140112
Conversation
6ca846c
to
1dd5162
Compare
packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart
Outdated
Show resolved
Hide resolved
d6ec9fe
to
7171e31
Compare
@christopherfujino I'm still a little confused about what the But in this code we're adding If the intention is to use However, I'm not sure whether using "windows" is the best option if we want to be able to conditionally show this per-project. We can't change which devices are available per-project, only filter by device-type. So the Preview device will always be sent to VS Code (when enabled) regardless of project capabilities, so if we want to be able to control its visibility (eg. to show it only when a project doesn't have plugins), I think it would need its own platform type. For example maybe the preview device should have a platformType of |
7171e31
to
224e6a6
Compare
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.
LGTM - I added some nits and maybe some tweaks to the structure of platformTypes
in the response that I think might help improve things in the client.
@@ -416,36 +416,129 @@ class DaemonDomain extends Domain { | |||
/// is correct. | |||
Future<Map<String, Object>> getSupportedPlatforms(Map<String, Object?> args) async { | |||
final String? projectRoot = _getStringArg(args, 'projectRoot', required: true); | |||
final List<String> result = <String>[]; | |||
final List<String> platforms = <String>[]; |
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.
nit: should we rename some of these variables (that aren't part of the API) platformType
and/or add a comment to make it a bit clearer that almost all code here is platform types and not platforms?
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.
I will change this variable name, but I would add that--in my mind--the situation is far more confusing than just that we use the wrong terminology here.
I don't think the tool has a standardized concept of what exactly a target platform is. It is probably roughly something like operating system + device architecture, but it's complicated by for example the web (js vs WASM), the tester device, the preview device, and custom devices. In particular, there is a lot of complexity in the build_info.dart library: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_info.dart#L509
Similarly, even though we have an enum named PlatformType
, I wouldn't call that a standardized concept in the tool.
} | ||
if (!supportedPlatforms.contains(SupportedPlatform.linux)) { | ||
isSupported = false; | ||
reasons.add('the current Flutter project does not have a Linux platform directory'); |
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.
Would something like "The Linux platform is not currently enabled for this project" read better? I'm thinking of when it's visible in the UI:
DEVICES
-------------------------------------------------------------------------- Available Devices
Chrome
Edge
-------------------------------------------------------------------------- Unavailable Devices
Enable Linux
The Linux platform is not currently enabled for this project
Enable macOS
The macOS platform is not enabled globally
Part of #130277