Enabling desktop platform on existing flutter project with different flavors

1,649

I had the same issue with web support and flavors. To resolve this, I've used a way around with:

flutter create --org <identifier-for-one-of-the-flavors> .

e.g. flutter create --org <com.example.flutter.staging> .

This created and made a setup for specific flavor only, with a new main file, assets, scheme (flavor) etc. But, I've deleted all generated files except web folder and everything works fine as before, but now with web support.

Share:
1,649
Nihad Delic
Author by

Nihad Delic

Updated on December 23, 2022

Comments

  • Nihad Delic
    Nihad Delic over 1 year

    I am having issues with adding desktop platforms to existing projects.

    I have followed their official docs on how to add macOS to the existing project. So basically you should:

    1. master or dev channel of flutter.
    2. should run flutter create . command

    On this command, I get stuck, because we are using different flavors, and as a result, after step 2 I am getting:

    [ +2 ms] The Xcode project defines schemes: APN, AppStore, Debug, Staging [ +12 ms] "flutter create" took 2,539ms. [ +6 ms] You must specify a --flavor option to select one of the available schemes.

    But the thing is that command flutter create does not have at all this option. So ofc, running flutter create --flavor=debug . will not work

    So the question is, does anyone know how to resolve this, and what's correct way of doing it?

    • Szepetry
      Szepetry over 3 years
      I think you haven't maybe enabled it or something or while running you didn't select the device correctly. Watch this video, He shows how to work with cross platform applications. It works for me.
    • Nihad Delic
      Nihad Delic over 3 years
      Hey, thanks for the reply, but he did everything from official documentation the same as I did :) It's not working
  • Nihad Delic
    Nihad Delic over 3 years
    Yep, unfortunately, workaround but it's working. I would add something like flutter create --org <com.example.flutter.staging> --platforms=macos . so you don't need to remove unwanted files. Thanks