Using this article you will be able to switch flutter channel easily for running flutter application on different platform devises. Flutter is currently under development and versions are being updated every day. As we all know we create multiple platform apps in flutter by using single dart code files but this also create confusion for how to run app on different platform. So, In this article, we will look how to run flutter app on different platform.
1. How to run flutter app on mobile
for running flutter app on android mobile phone first check the flutter channel using this command
$ flutter channel
it should be on stable channel. because currently in flutter, stable channel is used for mobile development. if it is not on the stable channel then bring it on the stable channel. using this command
$ flutter channel stable
then run the flutter upgrade for upgrading flutter sdk. This command may take time to be fully executed.
$ flutter upgrade
after that open the virtual device using emulator / simulator or connect your real device to the software IDE(android studio or visual studio) for running the app but first find the connected device by running this command
$ flutter devices
after that run the flutter app by
$ flutter run
this above command will launch the flutter mobile app in your connected phone.
Note -->You might also run $ flutter doctor
to see if there are any unresolved issues. now
2. for running Desktop App
first switch flutter channel to dev channel using
$ flutter channel dev
then upgrade the flutter sdk run
$ flutter upgrade
to enable setting for desktop run
$ set Enable_FLUTTER_DESKTOP=true
and after that run
$ flutter config --enable-windows-desktop
Where <platform> is windows, macOS, or Linux:
To add desktop support to an existing project, run the following command in a terminal from the root project directory:
$ flutter create .
Note point :- Please install the Visual Studio and “Desktop development with C++” workload, including all of its default components if not installed in your system. You might also run $ flutter doctor
to see if there are any unresolved issues.
To ensure that desktop is installed, list the devices available. by running
$ flutter devices
To launch your app from the command line, enter commands from the top of the package: for windows
$ flutter run -d windows
change OS name according to your desktop app. for Linux windows, macOS
3. for web App
Run the following commands to use the latest version of the Flutter SDK from the beta channel and enable web support:
$ flutter channel beta$ flutter upgrade$ flutter config --enable-web
To add web support to an existing project, run the following command in a terminal from the root project directory:
$ flutter create .
Once web is enabled, the flutter devices command outputs a Chrome device that opens the Chrome browser with your app running, and a Web Server that provides the URL serving the app.
$ flutter devices
To serve your app from localhost in Chrome, enter the following from the top of the package:
$ flutter run -d chrome
using these commands you can run flutter application on different platform. and you can run app using android studio software also.
Locate the main Android Studio toolbar:
In the target selector, select an Android device for running the app. If none are listed as available, select Tools> Android > AVD Manager and create one there.
Click the run icon in the toolbar, or invoke the menu item Run > Run.
You can download pdf from my GitHub account
Live demo is available at
References
It’s always good to give references
If you find something wrong with my code or approach, do mention it in the comments, I would love to improve.
Hello, I am Vinay. A creative developer and a logical designer. You can find me on YouTube or stalk me on GitHub or follow me on Instagram? If that’s too social for you, just drop a mail to vinayraj034@gmail.com if you wish to talk tech with me.