How to Disable Desktop Support in Flutter
In this article
To disable desktop support in Flutter, you remove the desktop platforms from the project's platform list and, if needed, delete the generated desktop folders. The exact command is flutter config --no-enable-windows-desktop (or the equivalent for macOS and Linux), but that only changes the global tool setting. For a single project, the cleaner method is to edit the project's platform configuration or simply delete the desktop runner folders. This guide covers both approaches, plus how to verify the change and what to do if something breaks.
What You'll Need
- Flutter SDK installed and available on your PATH (run
flutter --versionto confirm). - A terminal or command prompt open in your project's root directory (the folder containing
pubspec.yaml). - Basic familiarity with editing files in a code editor.
- Optional: a backup or version control commit before deleting folders, so you can restore them if needed.
Step-by-Step
- Check which platforms are currently enabled. Run
flutter devicesandflutter configin your terminal. The config output lists which desktop platforms are turned on globally. Note that menu labels and output wording can differ slightly between Flutter versions and operating systems, so read the lines rather than expecting an exact match. - Decide whether you want a global or per-project change. Global changes affect every Flutter project on your machine. Per-project changes affect only the current app. For most people, per-project is safer because it does not surprise you later when working on a different app.
- For a global change, disable the desktop platform. Run the command for your operating system:
- Windows:
flutter config --no-enable-windows-desktop - macOS:
flutter config --no-enable-macos-desktop - Linux:
flutter config --no-enable-linux-desktop
- Windows:
- For a per-project change, remove the desktop folders. In your project root, delete the
windows/,macos/, orlinux/folder depending on which desktop target you want gone. These folders contain the native runner code and generated build files. Deleting them means the project can no longer be built for that desktop platform until you regenerate them. - Check the project's platform list. Open
pubspec.yamland look for aflutter:section. If there is aplatforms:entry that lists desktop platforms, remove those lines. Not every project has this section, so skip this step if it is absent. Do not remove mobile or web entries you still need. - Clean the build output. Run
flutter cleanin the project root. This deletes thebuild/directory, which may still contain compiled desktop artifacts from earlier builds. It is safe and does not touch your source code. - Re-fetch dependencies. Run
flutter pub getso the tool regenerates the plugin registrant files for the remaining platforms. Without this, some plugins may still reference the desktop platform you removed. - Verify the change. Run
flutter devicesagain. The desktop device you disabled should no longer appear. You can also runflutter run -d windows(or the matching device ID) and confirm that Flutter reports no such device instead of launching the app. - Test the remaining targets. Build and run the app on the platform you still support, for example
flutter run -d chromefor web orflutter runwith a connected phone. This confirms that removing the desktop folders did not break shared code.
Common Mistakes
- Disabling globally when you meant one project. The
flutter configcommands affect every project on the machine. If you only want one app to stop targeting desktop, delete that project's desktop folder instead. - Deleting the desktop folder without a backup. The folder contains native runner code you may have customised. Commit to version control first, or copy the folder somewhere safe, so you can restore it.
- Forgetting
flutter clean. Old build artifacts can make it look like desktop support is still active. Cleaning forces a fresh build for the remaining platforms. - Editing
pubspec.yamlincorrectly. YAML is indentation-sensitive. If you remove a platform entry, keep the remaining indentation consistent orflutter pub getwill fail with a parse error. - Assuming plugins will behave the same. Some plugins declare desktop support in their own configuration. If a plugin still lists a desktop platform, you may see warnings after removal. Check the plugin's documentation for how to exclude it.
Tips
- Use version control (Git) before making structural changes. A commit lets you undo a folder deletion in seconds.
- If you might want desktop support back later, prefer the
flutter configmethod over deleting folders, because re-enabling is a single command. - To re-enable a desktop platform globally, run the same command without
--no-, for exampleflutter config --enable-windows-desktop. - To regenerate a deleted desktop folder, run
flutter create --platforms=windows .from the project root (replacewindowswithmacosorlinuxas needed). This recreates the runner files but does not restore custom edits. - Keep your Flutter SDK updated. Command names and config output can change between versions, so check
flutter config --helpif a command is not recognised.
Troubleshooting
If the desktop device still appears after you disabled it, run flutter clean and then flutter devices again. If it persists, close and reopen your terminal so the tool picks up the new configuration.
If flutter pub get fails after editing pubspec.yaml, the file likely has an indentation error. Restore the file from version control or re-add the section carefully, matching the indentation of neighbouring keys.
If your app fails to build on mobile or web after removing the desktop folder, check for imports or conditional code that reference desktop-only packages. Search your project for platform checks such as Platform.isWindows and make sure they are guarded or removed where appropriate.
If a plugin reports that it is missing a platform implementation, review its documentation. Some plugins require you to explicitly list supported platforms, and removing a desktop platform from your app may require adjusting the plugin's configuration in pubspec.yaml.
If you deleted a desktop folder by mistake, restore it from version control or regenerate it with flutter create --platforms=windows . (or the matching platform). Custom native code will not be restored by regeneration, which is why a backup matters.
Frequently Asked Questions
Does disabling desktop support remove the desktop folders automatically?
No. The flutter config commands only change which platforms the Flutter tool treats as available. To remove the folders, you must delete them manually or use a script.
Will disabling desktop support break my mobile or web builds?
It should not, as long as your shared Dart code does not rely on desktop-only plugins or platform checks. Run a build for your remaining targets to confirm.
Can I disable desktop support for just one project?
Yes. Delete that project's windows/, macos/, or linux/ folder and remove any desktop entries from pubspec.yaml. This leaves other projects unaffected.
How do I turn desktop support back on?
Run the matching flutter config --enable-... command, or regenerate the folder with flutter create --platforms=windows . from the project root.
Is there a single command to disable all desktop platforms at once?
There is no single built-in command that disables Windows, macOS, and Linux together. Run the individual --no-enable- command for each platform you want to turn off.
Does this affect Flutter web support?
No. Web is a separate platform target. Disabling desktop support does not change web availability, and you can still run flutter run -d chrome.