Home > database >  how to enable or switch existing flutter project (mobile only) to MacOS or WEB or Linux or Windows?
how to enable or switch existing flutter project (mobile only) to MacOS or WEB or Linux or Windows?

Time:11-09

I have made a flutter app only for mobile (Android and IOS). now client requested that make it for web/macOS/windows app.

so now how can I enable the existing projects for all other platforms or wise wars? here is all case I want to know

  1. Existing on the web and adding other (mobile, windows, mac)
  2. Existing on the web and adding only (mobile)
  3. Existing on the Mobile and adding other (web, windows, mac)
  4. Existing on Mobile and adding only (windows, mac)
  5. Existing on the Mac and adding other (mobile, windows, web)
  6. Existing on Windows and adding other (mobile, web)

many many thanks in advance. Questions and answers will be useful for many flutter developers in the future so if possible then a details answer will be appreciated!

CodePudding user response:

flutter create --platforms=windows,macos,linux .

Is the one command that you need to run in terminal of your root project directory. You can specify platforms in the comma seperated list.

Like mentioned in the doc https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app

List of platforms:https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app

To enable disable platforms let say we want to disable ios altogether you can use and create a project later. Now you wont have ios as it is not available.

Well you can toggle the config and simply run the above mentioned command to go for ios

flutter config --no-enable-ios

You can follow this link for the config commands. https://docs.flutter.dev/development/platform-integration/desktop#set-up

So lets say you have a case where you need to add only windows and mac you can disable other platforms and use the create command.

Now for the existing project if you want to enable or add a platform you can use the above create with platforms flag

NOTE: CONFIG SETTINGS ARE USUALLY GLOBAL There are many ways we can counter it. we can make use isolated development too complicated for simple usecase.

We can use FVM https://fvm.app/ for the configs so that it doesnot affect our core sdk.

  • Related