Flutter Enable Desktop Application

Published August 15, 2021

We all knows that flutter will support different types platforms like Android and iOS mobile applications, Flutter web, TV now it become to support Desktop platform also. This will support on Mac, Windows and Linux also

 

Requirement for Flutter Desktop application for different Operating systems

  • Windows: Visual Studio 2019  (not to be confused with Visual Studio Code). For Win32 you need the Desktop development with C++” workload installed, including all of its default components. For UWP you need the “Universal Windows Platform development” workload installed, with the optional UWP C++ tools
  • MacOS: Xcode and CocaoPods installed
  • Linux: Clang, Cmake, GTK development headers, Ninja build, and pkg-config.

 

Flutter Enabling Desktop Application

 

How to Enable Flutter for desktop application

To enable flutter for desktop application we need to run the below command

flutter config --enable-<platform>-desktop

 

Here the platform will be window, or macos or linux

 

Below are the commands based on the OS

flutter config --enable-windows-desktop
flutter config --enable-macos-desktop
flutter config --enable-linux-desktop

 

To run desktop we need to find the connected devices, for this if we run the below code it will list all the connected devices list

flutter devices

2 connected devices:

Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 6.3.9600]
Chrome (web)      • chrome  • web-javascript • Google Chrome 92.0.4515.131

 

Let's create flutter desktop application

flutter create myapp

 

How to run the flutter application on desktop

To run the flutter application on desktop we need to run the below commands

flutter run

 

when we execute above command it will give you like below

Multiple devices found:
Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 6.3.9600]
Chrome (web)      • chrome  • web-javascript • Google Chrome 92.0.4515.131
[1]: Windows (windows)
[2]: Chrome (chrome)
Please choose one (To quit, press "q/Q"): 1
Launching lib\main.dart on Windows in debug mode...

 

 

Or we can directly run like below

flutter run -d macos
flutter run -d windows
flutter run -d linux

 

And that's it we are now ready with flutter desktop application and we can run on the desktop. If you have any doubts about desktop app configuration visit official website

 

In the next tutorial we will create Flutter Navigation drawer for desktop application

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

532 Views