Skip to content

When asking to add a platform to a project, it should use flutter create --empty #5494

@gspencergoog

Description

@gspencergoog

Describe the bug
When I run a project on a platform that isn't currently supported by the project, the extension asks me to add the desired platforms, which makes sense.

But when it adds it, it uses the flutter create --platform=linux command, which not only adds the platform, it also creates things like a test/main_test.dart, which are unrelated to adding a platform, and are confusing if you already have a project with a main.dart, but no test called main_test.dart, since now you have a test that fails if you run it, and you have no idea where that came from.

The flutter create command has an --empty argument which limits the creation of new files and simplifies the files it does create to the minimum.

Adding platforms should use that.

The --empty arg should probably write fewer things too (it currently writes a plain README.md which is unnecessary), but that's not an extension bug.

To Reproduce
Steps to reproduce the behavior:

  1. Create a project that has no platform directories.
  2. Try to run the main.
  3. When asked, say you want to add the desktop platform you're running on.
  4. Notice that there is a test/test_main.dart file.

Expected behavior
Adding a platform should only add a platform, not create extra files.

Workspace Environment
Dart Code extension: 3.108.2
Flutter extension: 3.108.0 (activated)

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

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

Dart (3.9.0-55.0.dev): /Users/user/code/flutter/bin/cache/dart-sdk
Flutter (3.32.0-1.0.pre.247): /Users/user/code/flutter (Chrome (web-javascript/web))

Output from 'dart info'

/Users/user/code/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.9.0-55.0.dev (dev) (Thu Apr 24 21:03:09 2025 -0700) on "macos_arm64"
  • on macos / Version 15.4.1 (Build 24E263)
  • locale is en

Process info

Memory CPU Elapsed time Command line
62 MB 0.0% 00:10 dart devtools --machine --allow-embedding --dtd-uri ws:/A8nNc_cJFEc=
1006 MB 176.8% 00:11 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.108.2
92 MB 0.0% 00:11 flutter_tools.snapshot daemon
Output from 'flutter doctor'

/Users/user/code/flutter/bin/flutter doctor -v

[!] Flutter (Channel main, 3.32.0-1.0.pre.247, on macOS 15.4.1 24E263 darwin-arm64, locale en) [1,838ms]
    • Flutter version 3.32.0-1.0.pre.247 on channel main at /Users/user/code/flutter
    ! The flutter binary is not on your path. Consider adding /Users/user/code/flutter/bin to your path.
    ! The dart binary is not on your path. Consider adding /Users/user/code/flutter/bin to your path.
    • Upstream repository git@github.com:flutter/flutter.git
    • Framework revision d6b1702e5f (2 hours ago), 2025-04-25 14:26:44 +0000
    • Engine revision d6b1702e5f
    • Dart version 3.9.0 (build 3.9.0-55.0.dev)
    • DevTools version 2.45.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [2.1s]
    • Android SDK at /Users/user/Library/Android/sdk
    • Emulator version 35.2.10.0 (build_id 12414864) (CL:N/A)
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /opt/homebrew/opt/openjdk/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Homebrew (build 23.0.1)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.3) [2.5s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    ! CocoaPods 1.11.3 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

[✓] Chrome - develop for the web [108ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1) [108ms]
    • 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 11.0.15+0-b2043.56-8887301)

[✓] Android Studio (version 4.0) [106ms]
    • Android Studio at /Users/user/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6514223/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 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2022.1.3) [106ms]
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.4
    • Dart plugin version 221.5921.27

[✓] VS Code (version 1.99.3) [10ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.108.0

[✓] Connected device (2 available) [6.6s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 136.0.7103.48

[✓] Network resources [200ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions