Flutter - Why is there a windows folder in my app?

143

It is created because it is listed as one of the default platforms of the flutter create command:

% flutter --help create

...

    --platforms              The platforms supported by this project. Platform folders (e.g. android/) will be generated
                             in the target project. This argument only works when "--template" is set to app or plugin.
                             When adding platforms to a plugin project, the pubspec.yaml will be updated with the
                             requested platform. Adding desktop platforms requires the corresponding desktop config
                             setting to be enabled.
                             [ios (default), android (default), windows (default), linux (default), macos (default), web
                             (default)]
...

It is there in case you want to build your app for Windows.

Yes, you can safely delete it.

If you ever regret deleting it and want to create it back, you can write flutter create . inside your project folder.

If you do not want it in your next project, you can specify platforms to be supported while creating the project:

flutter create --platforms ios,android my_new_project
Share:
143
who-aditya-nawandar
Author by

who-aditya-nawandar

Updated on January 04, 2023

Comments

  • who-aditya-nawandar
    who-aditya-nawandar over 1 year

    I have a folder named windows in my Flutter app. It's also causing some C++ and other files to show up in source control changes.

    Is it safe to delete this folder if I am not developing for windows? Why and how could it have come there?

    • Ruchit
      Ruchit almost 2 years
      yes it is safe to delete that folder, it's only use form when you are doing windows development
  • who-aditya-nawandar
    who-aditya-nawandar almost 2 years
    No, I mean it appeared all of a sudden in my project. I never saw the windows folder in any of my other flutter projects.
  • Gazihan Alankus
    Gazihan Alankus almost 2 years
    Are you sure this project did not have it before? I think it could be that your other projects were created with an older version of Flutter and this was created with a newer one that supports the windows platform.