Dart-Code / Dart-Code

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

VS code not able to recognize my project as a Flutter project and instead runs as a Dart project #4720

Closed yashpalzala closed 10 months ago

yashpalzala commented 10 months ago

Describe the bug VS code not able to recognize my project as a Flutter project and instead runs as a Dart project. There have been no changes in any config files or pubspec files.

To Reproduce Steps to reproduce the behavior:

  1. Just try to run the project in debug mode

Expected behavior The project should run normally as a Flutter project.

Screenshots dart code startup log(Line 212 mentions that this project is not recognized as a Flutter project) - image

Please complete the following information:

Flutter doctor output -

Flutter (Channel stable, 3.7.1, on Microsoft Windows [Version 10.0.22621.2134], locale en-IN)
    • Flutter version 3.7.1 on channel stable at D:\fvm-flutter\3.7.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7048ed95a5 (7 months ago), 2023-02-01 09:07:31 -0800
    • Engine revision 800594f1f4
    • Dart version 2.19.1
    • DevTools version 2.20.1

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\yzala\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33627.172
    • Windows 10 SDK version 10.0.22000.0

[✓] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.6+0-b2043.56-9586694)

[✓] VS Code (version 1.81.1)
    • VS Code at C:\Users\yzala\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.72.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.2134]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 116.0.5845.141
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 115.0.1901.203

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.`

Pubspec.yaml file -

name: ninja_study
description: A new Flutter project.
publish_to: 'none'
version: 1.0.61+66

environment:
  sdk: ">=2.17.2 <3.0.0"

dependencies:
  agora_rtc_engine: ^6.1.0
  android_id: ^0.1.3+1
  android_play_install_referrer: ^0.2.1
  android_sms_consent: ^1.0.1
  audio_waveforms: ^0.1.4
  audiofileplayer: ^2.1.0
  audioplayers: ^4.1.0
  auto_size_text: ^3.0.0
  cached_network_image: ^3.2.3
  carousel_slider: ^4.2.1
  clean_calendar: ^1.1.0
  cloud_firestore: ^3.5.1
  confetti: ^0.7.0
  connectivity_plus: ^2.3.6
  country_codes: ^2.2.0
  country_picker: ^2.0.15
  dart_jsonwebtoken: ^2.6.2
  device_info_plus: ^8.1.0
  dio: ^5.3.0
  disable_battery_optimization: ^1.1.0+1
  dotted_border: ^2.0.0+3
  expandable: ^5.0.1
  facebook_app_events: ^0.18.3
  firebase_analytics: ^9.1.7
  firebase_auth: ^3.3.18
  firebase_core: ^1.16.0
  firebase_crashlytics: ^2.8.0
  firebase_dynamic_links: ^4.3.3
  firebase_messaging: ^11.4.4
  flutter_azure_tts:
    git:
      url: https://github.com/yashpalzala/flutter_azure_tts.git
      ref: 4c6436fb0bdef514a6d6c9071f059926bc2b4adf
  flutter_background: ^1.2.0
  flutter_chat_bubble: ^2.0.0
  flutter_glow: ^0.2.0
  flutter_holo_date_picker: ^1.0.6
  flutter_local_notifications: ^15.1.0+1
  flutter_rating_bar: ^4.0.1
  flutter_sound_lite: ^8.5.0
  flutter_stripe: ^9.2.2
  flutter_svg: ^1.1.6
  flutter_tts: ^3.6.3
  flutter_web_browser: ^0.17.1
  fluttertoast: ^8.1.2
  font_awesome_flutter: ^10.3.0
  get: ^4.6.1
  google_sign_in: ^5.3.1
  google_speech: ^2.1.2
  hive: ^2.2.3
  http: ^0.13.5
  in_app_purchase: ^3.1.8
  in_app_review: ^2.0.6
  info_popup: ^2.4.6
  internet_connection_checker: ^1.0.0+1
  intl: ^0.17.0
  jiffy: ^5.0.0
  json_annotation: ^4.7.0
  just_audio: ^0.9.31
  lottie: ^2.2.0
  mixpanel_flutter: ^2.1.1
  overlay_support: ^2.1.0
  package_info: ^2.0.2
  path_provider: ^2.0.11
  percent_indicator: ^4.2.2
  permission_handler: ^10.2.0
  pin_code_fields: ^7.4.0
  purchases_flutter: ^5.6.4
  rxdart: ^0.27.7
  scrollview_observer: ^1.15.0
  share: ^2.0.4
  shared_preferences: ^2.0.16
  shimmer: ^2.0.0
  sign_in_with_apple: ^4.1.0
  smooth_page_indicator: ^1.0.0+2
  speech_to_text: ^6.1.1
  store_redirect: ^2.0.1
  styled_text: ^7.0.0
  super_tooltip: ^2.0.4
  swipeable_button_view: ^0.0.2
  syncfusion_flutter_charts: ^21.2.3
  timelines: ^0.1.0
  translator: ^0.1.7
  tutorial_coach_mark: ^1.2.4
  url_launcher: ^6.1.7
  video_player: ^2.4.10
  visibility_detector: ^0.3.3
  wakelock: ^0.6.2
  wave: ^0.2.2
  web_socket_channel: ^2.3.0
  youtube_player_flutter: ^8.1.2

dependency_overrides:
  firebase_core_platform_interface: 4.5.1
  json_annotation: 4.8.1

dev_dependencies:
  build_runner: ^2.1.2
  device_preview: ^1.1.0
  flutter_inappwebview: ^5.7.2+3
  flutter_launcher_icons: ^0.11.0
  flutter_lints: ^2.0.2
  flutter_test:
    sdk: flutter
  hive_generator: ^1.1.1
  json_serializable: ^6.2.0

flutter:

  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/
    - assets/animations/
    - assets/audio/
    - assets/icons/
    - assets/avatar/
    - assets/

  # example:
  fonts:
    - family: Poppins
      fonts:
        - asset: assets/font/Poppins-Regular.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-Black.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-Bold.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-ExtraBold.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-ExtraLight.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-Light.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-Medium.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-Regular.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-SemiBold.ttf

    - family: Inter
      fonts:
        - asset: assets/font/inter/Inter-Thin.ttf
DanTup commented 10 months ago

@yashpalzala it looks like you don't have flutter listed as a dependency in your pubspec.yaml. You should have something like:

dependencies:
  flutter:
    sdk: flutter

You should list all packages your project requires in dependencies, including Flutter. This is what Dart-Code uses to determine whether your project is a Flutter project or not.

yashpalzala commented 10 months ago

@yashpalzala it looks like you don't have flutter listed as a dependency in your pubspec.yaml. You should have something like:

dependencies:
  flutter:
    sdk: flutter

You should list all packages your project requires in dependencies, including Flutter. This is what Dart-Code uses to determine whether your project is a Flutter project or not.

Yep, figured it just now. Thanks for your swift reply and solution.

DanTup commented 10 months ago

np, glad it was something simple! :)

yashpalzala commented 10 months ago

Hi @DanTup , I did some digging and saw that my previous branches/ releases don't have dependencies: flutter: sdk: flutter and we were able to continue our work till now. So how come this issue popped up suddenly?

DanTup commented 10 months ago

So how come this issue popped up suddenly?

It's because in the latest update the check for flutter was made more strict. It used to be a simple string check which had false positives (such as when the flutter reference was commented out). It's now working as it really always should have.

If you have the depend_on_referenced_packages lint enabled I would expect that it should have alerted you to this issue. If you don't, I would recommend enabling it (it's in the core, recommended and flutter lint sets).

Hope this makes sense!