Dart-Code / Dart-Code

Dart and Flutter support for VS Code
https://dartcode.org/
MIT License
1.49k stars 303 forks source link

Target devices for nested application don't show up as available devices in a particular case #5250

Open jtarkowski27 opened 1 week ago

jtarkowski27 commented 1 week ago

Describe the bug In one of our projects we have a problem that macos and web devices are not showing up as "Available devices" for nested flutter application in the project directory that has said targets defined. The problem is that I can't reproduce the issue by replicating the project structure using flutter empty applictions/packages. This tells me that the problematic project has something that messes up with "Dart-Code" VSC extension, but I can't really tell what that is. I would be very grateful if you could explain how "Dart-Code" searches for available devices within the entire opened directory tree. Even better, if you could identify the cause of the issue based solely on the information provided below, it would be immensely helpful.

To Reproduce As I mentioned before, I’m unable to provide steps to reproduce the issue since it doesn’t happen with an empty project that has a similar folder structure but on a smaller scale. However, I created an example project that shows up available devices properly, which you can find here:

https://github.com/jtarkowski27/nested_application_example

When you open this example as a workspace in VS Code, you should be able to see all the target devices.

The project where the issue comes up consists of of three modules:

  1. Root app that is at the root of the directory (supports ios and android)
  2. app_design_system which is package of common widgets placed in packages/app_design_system
  3. app_widgetbook which is a flutter application that lists up all components from app_design_system and is located at packages/app_widgetbook (supports ios, macos and web)

Folder structure looks more or less like this:

./ // A main application at the root of the project 
├── .dart_tool/
├── .git/
├── .github/
├── .idea/
├── .run/
├── android/
├── assets/
├── documentation/
├── generator/
├── ios/
├── lib/
├── packages/
│   ├── app_design_system/ // A flutter package with common widgets
│   │   ├── .dart_tool/
│   │   ├── .idea/
│   │   ├── .vscode/
│   │   ├── assets/
│   │   ├── fonts/
│   │   ├── lib/
│   │   ├── test/
│   │   ├── tool/
│   │   ├── .DS_Store
│   │   ├── .env
│   │   ├── .gitignore
│   │   ├── .metadata
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── analysis_options.yaml
│   │   ├── app_design_system.iml
│   │   ├── custom_lint.log
│   │   ├── dart_test.yaml
│   │   ├── l10n.yaml
│   │   ├── pubspec.lock
│   │   └── pubspec.yaml
│   ├── app_widgetbook/ // A flutter applications that presents common widgets from app_design_system
│   │   ├── .azure/
│   │   ├── .dart_tool/
│   │   ├── .idea/
│   │   ├── assets/
│   │   ├── ios/
│   │   ├── lib/
│   │   ├── macos/
│   │   ├── test/
│   │   ├── web/
│   │   ├── .DS_Store
│   │   ├── .gitignore
│   │   ├── .metadata
│   │   ├── analysis_options.yaml
│   │   ├── app_widgetbook.iml
│   │   ├── custom_lint.log
│   │   ├── pubspec.lock
│   │   └── pubspec.yaml
│   ├── .DS_Store
│   └── custom_lint.log
├── test/
├── tools/
├── .DS_Store
├── .flutter-plugins
├── .flutter-plugins-dependencies
├── .fvmrc
├── .gitattributes
├── .gitignore
├── .metadata
├── .rubocop.yml
├── README.md
├── analysis_options.yaml
├── bitrise.yaml
├── contracts_generator.yaml
├── custom_lint.log
├── l10n.yaml
├── app.code-workspace
├── app.iml
├── pubspec.lock
└── pubspec.yaml

Expected behavior "Select a device to use" should all below options (as it does in example that I've made) image

Screenshots As you can see macos and web devices are unavailable to select even though app_widgetbook has directories for them. This is the screenshot from project where this issue occurs. Screenshot 2024-09-06 at 08 39 07

Please complete the following information:

Workspace Environment
Dart Code extension: 3.96.0
Flutter extension: 3.96.0 (activated)

App: Visual Studio Code
App Host: desktop
Version: mac 1.92.2

Workspace type: Dart, Flutter (LSP)
Workspace name: leancode_flutter_template

Dart (3.4.4): /Users/jakubtarkowski/development/flutter/bin/cache/dart-sdk
Flutter (3.22.3): /Users/jakubtarkowski/development/flutter (macOS (darwin/macos))

Output from 'dart info' `/Users/jakubtarkowski/development/flutter/bin/cache/dart-sdk/bin/dart info` If providing this information as part of reporting a bug, please review the information below to ensure it only contains things you're comfortable posting publicly. #### General info - Dart 3.4.4 (stable) (Wed Jun 12 15:54:31 2024 +0000) on "macos_arm64" - on macos / Version 14.4 (Build 23E214) - locale is en-PL #### Project info - sdk constraint: '>=3.4.0 <4.0.0' - dependencies: bloc_dispose_scope, bloc_presentation, clock, collection, configcat_client, cqrs, enhanced_gradients, firebase_core, firebase_crashlytics, firebase_messaging, firebase_performance, flutter, flutter_bloc, flutter_gen, flutter_hooks, flutter_local_notifications, flutter_localizations, flutter_native_splash, flutter_svg, freezed_annotation, go_router, google_sign_in, http, intl, json_annotation, jwt_decoder, leancode_contracts, leancode_cubit_utils, leancode_debug_page, leancode_flutter_svg_adaptive_loader, leancode_forms, leancode_hooks, logging, logging_bugfender, package_info_plus, provider, shared_preferences, sign_in_with_apple, timeago, timeago_flutter, url_launcher, uuid - dev_dependencies: bloc_test, build_runner, custom_lint, flutter_gen_runner, flutter_launcher_icons, flutter_test, freezed, go_router_builder, integration_test, json_serializable, leancode_lint, patrol - elided dependencies: 9 #### Process info | Memory | CPU | Elapsed time | Command line | | ------: | ---: | -----------: | ------------------------------------------------------------------------------- | | 27 MB | 0.0% | 12:25:16 | dart devtools --machine --allow-embedding --dtd-uri ws:/5ihoxfXgPaXh4POZ | | 71 MB | 0.0% | 02:49 | dart devtools --machine --allow-embedding --dtd-uri ws:/BH4YDShAvv3OkoeU | | 67 MB | 0.0% | 05:20 | dart devtools --machine --allow-embedding --dtd-uri ws:/NLOKIlU9Sb3OYY6V | | 27 MB | 0.0% | 42:50 | dart devtools --machine --allow-embedding --dtd-uri ws:/kWKBlStOFrPpuw83 | | 30 MB | 0.0% | 18:24:53 | dart devtools --no-launch-browser | | 331 MB | 0.0% | 05:21 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.96.0 | | 921 MB | 0.0% | 02:49 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.96.0 | | 117 MB | 0.0% | 12:25:17 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.96.0 | | 365 MB | 0.0% | 42:51 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.96.0 | | 48 MB | 0.0% | 12:25:07 | dart lib/custom_lint_client.dart ::1 51259 | | 872 MB | 0.0% | 42:39 | dart lib/custom_lint_client.dart ::1 53428 | | 1097 MB | 0.0% | 02:39 | dart lib/custom_lint_client.dart ::1 58819 | | 70 MB | 0.0% | 05:21 | dart tooling-daemon --machine | | 69 MB | 0.0% | 02:49 | dart tooling-daemon --machine | | 27 MB | 0.0% | 12:25:17 | dart tooling-daemon --machine | | 27 MB | 0.0% | 42:51 | dart tooling-daemon --machine | | 87 MB | 0.0% | 05:21 | flutter_tools.snapshot daemon | | 82 MB | 0.1% | 02:49 | flutter_tools.snapshot daemon | | 51 MB | 0.0% | 12:25:17 | flutter_tools.snapshot daemon | | 63 MB | 0.0% | 42:51 | flutter_tools.snapshot daemon |
Output from 'flutter doctor' `/Users/jakubtarkowski/development/flutter/bin/flutter doctor -v` ```text [✓] Flutter (Channel stable, 3.22.3, on macOS 14.4 23E214 darwin-arm64, locale en-PL) • Flutter version 3.22.3 on channel stable at /Users/jakubtarkowski/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b0850beeb2 (7 weeks ago), 2024-07-16 21:43:41 -0700 • Engine revision 235db911ba • Dart version 3.4.4 • DevTools version 2.34.3 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/jakubtarkowski/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/jakubtarkowski/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) [✓] IntelliJ IDEA Community Edition (version 2023.1.7) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 78.2.1 • Dart plugin version 231.9414.10 [✓] VS Code (version 1.92.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.96.0 [✓] Connected device (5 available) • kubakubakuba (2) (mobile) • 00008110-001875C0140A201E • ios • iOS 17.5.1 21F90 • iPhone 15 Pro (mobile) • 361351EA-5008-47AC-BCEA-7F573E2D343C • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.4 23E214 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4 23E214 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.119 [✓] Network resources • All expected network resources are available. • No issues found! ```
DanTup commented 1 week ago

@jtarkowski27 are the projects more deeply nested in the problematic workspace?

There is a setting that controls how deep we'll walk through the workspace looking for Dart projects the defaults to 5:

image

You may need to increase that (which you can do in the Workspace Settings if you want to share for that repo) if your projects are deeper than that.

jtarkowski27 commented 1 week ago

@DanTup Maximum depth is 2 or 3 (relative to the root of the project) which is packages/app_widgetbook that has macos and web targets. I changed the depth in workspace settings to 10 just to be sure and restarted VSC but it doesn't help my case unfortunately.

DanTup commented 1 week ago

Could you try:

If there's nothing sensitive in the log you can share it here, otherwise look for lines that call getSupportedPlatforms and the matching response (by id):

[10:37:18 AM] [FlutterDaemon] [Info] ==> [{"id":"3","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"C:\\Dev\\Test Projects\\flutter_counter"}}]
[10:37:18 AM] [FlutterDaemon] [Info] <== [{"id":"3","result":{"platforms":["web","android","windows"],"platformTypes":{"web":{"isSupported":true},"android":{"isSupported":true},"ios":{"isSupported":false,"reasons":[{"reasonText":"the iOS platform is not enabled for this project","fixText":"Run \"flutter create --platforms=ios .\" in your application directory","fixCode":"create"}]},"linux":{"isSupported":false,"reasons":[{"reasonText":"the Linux platform is not enabled for this project","fixText":"Run \"flutter create --platforms=linux .\" in your application directory","fixCode":"create"}]},"macos":{"isSupported":false,"reasons":[{"reasonText":"the macOS platform is not enabled for this project","fixText":"Run \"flutter create --platforms=macos .\" in your application directory","fixCode":"create"}]},"windows":{"isSupported":true},"fuchsia":{"isSupported":false,"reasons":[{"reasonText":"the Fuchsia feature is not enabled","fixText":"Run \"flutter config --enable-fuchsia\"","fixCode":"config"},{"reasonText":"the Fuchsia platform is not enabled for this project","fixText":"Run \"flutter create --platforms=fuchsia .\" in your application directory","fixCode":"create"}]},"custom":{"isSupported":false,"reasons":[{"reasonText":"the custom devices feature is not enabled","fixText":"Run \"flutter config --enable-custom-devices\"","fixCode":"config"}]},"windowsPreview":{"isSupported":false,"reasons":[{"reasonText":"the Preview Device feature is not enabled","fixText":"Run \"flutter config --enable-flutter-preview","fixCode":"config"}]}}}}]

In particular, see if there are calls that have the problematic project as the projectRoot in params, and what the response looks like.

DanTup commented 1 week ago

By the way, I think all those checks currently do is check for the ios and macos folders in your project, so I guess it's also worth verifying whether the problematic project has those folders or not. If not, selecting the "Enable macOS" and "Enabled web" options in the device selector will help you create them which may fix the issue.