Create Flutter Application that support Web, Android, iOS and Desktop
It has never been easier to create applications that could run on multiple platforms.
In Flutter addition to developing for mobile device we can also create applications that can be executed in Desktop, Linux, Web and Mac.
In this article we will learn how to change channel, active suporte for windows, Linux, Mac and Web, and also connect our project to a repository on gitHub.
Prerequisites
[x] - Flutter
[x] - Visual Studio (with de plugin "Desktop development with C++")
[x] - Android Studio
[x] - Visual Studio Code
[x] - Chorme
Let’s star..
First we open the command line (Windows+R)
to see which channel we are in, executing the following command:
> flutter channel
We have to be in the channel master because it’s the only one who supports all operating systems, the channel dev don’t support Windows, Mac, Web and Linux, and the channel stable don’t support Windows.
For change channel we use the following command:
> flutter channel <name channel>
Now we upgrade flutter:
> flutter upgrade
After that we must enable the support for Windows, Mac andLinux, by executing the following command:
> flutter config --enable-macos-desktop
> flutter config --enable-linux-desktop
> flutter config --enable-windows-desktop
Then to see the enabled operating systems, run the following command
> flutter config -h
Create Project
Now we create the project with specific package for Android and iOS, for that we will use the following command
> flutter create --org <name package> <name app>
Upload the project to an GitHub repository
First open github an create your repository…
Open your project in Android Studio or Visual Studio Code or navegate to the project directory and in the terminal you will enter these commands:
> git init .
> git remote add origin <URL your repository in gitHub>
> git add .
> git commit -m "first commit"
> git fetch
> git push --set-upstream origin develop
Running The Demo App
To run the project click the run button inside Android Studio or from the terminalflutter run
The result should be something like this.
And that’s it for today !