DEV Community

Cover image for How to Create a Flutter Project for Either Web, IOS, Android, Mac OS, Windows and Linux
Stephen Michael
Stephen Michael

Posted on • Originally published at axxellanceblog.com

How to Create a Flutter Project for Either Web, IOS, Android, Mac OS, Windows and Linux

Introduction

In this article, I will show you how to create a flutter project for any specific platform only, either web, android, IOS, mac OS, windows, or Linux. creating the next big thing with flutter can be overwhelming, so I believe we should focus more on the thing that matters, so if this article is for you kindly enjoy it.

The original source of this article can be found here.

What is flutter?

Well if for any reason you find yourself here, I want to believe you already know what flutter is all about by now, but for some of you that don't know or maybe you knew but you have forgotten 😅, well let me remind you of how the flutter website put it:

Flutter is an open-source framework by Google for building beautiful, natively compiled, multi-platform applications from a single codebase.

Well, I do believe that the above explanation does explain a lot about flutter, but if you still don't understand you can simply head on to the official flutter website. now let us dive into how we can get this done.

Flutter Project for Only Web

To create a flutter project for only the web you can simply use the --platforms parameter to specify which platforms you want to create the app for (defaults to all of them). So, if you want to create an app for only the web you would do something like the following:

flutter create --platforms web my_app
Enter fullscreen mode Exit fullscreen mode

Note: simply replace my_app with your project name.

Flutter Project for Only Android

To create a flutter project for only android you can simply use the same --platforms parameter to specify which platforms you want to create the app for. So, if you want to create an app for only android you would do something like the following:

flutter create --platforms android my_app

Note: simply replace my_app with your project name.

Flutter Project for Only IOS

creating a flutter project for only IOS is not so different from the way you will create it for an android project. Just replace the android parameter with ios, simply enter this command on your terminal:

flutter create --platforms ios my_app
Enter fullscreen mode Exit fullscreen mode

Note: simply replace my_app with your project name.

Flutter Project for Only Window

To create a flutter project for only windows, just type in this command on your terminal:

flutter create --platforms windows my_app
Enter fullscreen mode Exit fullscreen mode

Note: simply replace my_app with your project name.

Flutter Project for Only Linux

To create a flutter project for only Linux, just type in this command on your terminal:

flutter create --platforms linux my_app
Enter fullscreen mode Exit fullscreen mode

Note: simply replace my_app with your project name.

Flutter Project for 2 or More Platforms

I for some reason have a feeling that you might want to create for only 2 or more specific platforms, and you might be wondering how will you do that, well fear no more the command is simply the same but this time you will have to combine the platform names with this symbol ,, for example here is the command to create a flutter project only window and android:

flutter create --platforms android, windows my_app
Enter fullscreen mode Exit fullscreen mode

Note: simply replace my_app with your project name.

Adding All Platforms Back

Well, if for any reason your want to get all platform's code backs, because maybe your project has enhanced or your user codebase has improved, you can simply run flutter create . to get all specific platforms back, or if you want to add specific platforms simply use this command:

flutter create --platforms=android .
Enter fullscreen mode Exit fullscreen mode

Note that after create there is a period (full stop) which will create android, ios, web and whichever isn't present in the project.

For Existing Flutter Project

I almost forgot to add this here, so if you have already created your flutter project with all platform directories added to it but then you only need it for a specific platform, you can simply delete the undesired platform directories after they are generated, this also works like a charm. you can also run this command on your terminal flutter --help create to get the full flutter help command.

Conclusion

Flutter is an amazing cross-platform framework for building multi-platform applications from a single codebase. so since a simple flutter create command will create for all platforms then I believe that with this article you can now create a flutter project for only the specific platform you will need it for. If by chance this blog post may have made your day or has helped you in any way, kindly show your support by commenting below on how it helped you, and don't forget to support me or this blog website by donating the little you can to us, as it helps us in creating more articles for the society. Thanks and have a great day.

Top comments (0)