How do I add Platforms to an Existing Flutter App/Project?

Viewed 10760

I created a Flutter app with mobile support only:

flutter create --platforms=ios,android foo

I also have another Flutter project that I created before web was supported by Flutter, which is why it only contains support for mobile.


Now, I want to run my app on web and macOS, but I receive the following error when trying to use flutter run -d macos:

Exception: No macOS desktop project configured. See https://flutter.dev/desktop#add-desktop-support-to-an-existing-app to learn about adding macOS support to a project.
1 Answers

You can add support for new plugins by recreating your project:

flutter create .

You can simply run this from the root of your Flutter project and it will add the required files for all platforms.


If you only want to add support for specific enabled platforms, you can do that by supplying the --platforms argument:

flutter create --platforms=web,macos .
Related