In addition to Web support, there is desktop support for compiling Flutter source code into native Windows, macOS, or Linux desktop applications.
It took a few hours to develop and package the Macos app with Flutter for the first time.http://101.37.147.31/Qools_v1.0.dmg
To make it easier to try out the desktop support for Flutter, the official Snapshot of the Flutter desktop Beta has been released on the Stable Channel. This means you can easily try desktop support without switching to the Flutter Beta channel. However, the snapshot contained in the stable channel will not be updated until the next Flutter stable release. Switch to the Flutter Beta channel if you want the latest desktop support.
Update the Flutter
Install or upgrade to the latest version first. You can also install multiple FLUTTER SDKS via FVM and switch
Install and manage the Flutter using FVM. If not installed, please refer to: FVM happily switches the Flutter version. Highly recommended!
FVM has been installed here. In the picture above, you can see which versions of FLUTTER are installed on this machine. Install the beta version with the following command
fvm install beta
Copy the code
Switch versions globally or within a project
fvm use beta --force
Copy the code
Because the host is configured with the FVM management version, by default, you add FVM to the flutter before the related commands. If you do not use the FVM to manage the version, you can remove the FVM from the following command.
Configuring the Desktop Platform
Flutter config –enable-
flutter config --enable-windows-desktop
flutter config --enable-macos-desktop
flutter config --enable-linux-desktop
Copy the code
Execute the command
fvm flutter config --enable-macos-desktop
Copy the code
To ensure that the device is enabled, run the following command to view available devices
fvm flutter devices
Copy the code
When you see the macOS device, it is configured and the MacOS desktop application is enabled. After desktop support is enabled, restart the IDE.
View flutter to detect native environment dependencies
flutter doctor
Copy the code
After you rely on OK, you can start creating your project.
Creating a desktop project
We are launching a new project, MAC_Demo, which requires Flutter Beta for macOS desktop application development:
mkdir mac_demo
cd mac_demo
fvm use beta --force
fvm flutter create .
Copy the code
Execute the above commands in sequence and you should see the MacOS folder in the project directory. If “XXX” appears in the command above is not a valid Dart package name. Dart. dev/tools/pub/p… dart.dev/tools/pub/p…
Run the MacOS desktop application
Run the project
fvm flutter run -d macos
Copy the code
Once the project is up and running, you can start building the desktop application you want.
Existing projects implement desktop support
To add desktop support to an existing Flutter project, CD to the project root directory and run it one by one
fvm use beta --force
fvm flutter create .
fvm flutter create --platforms=windows,macos,linux .
Copy the code
Before that, switch to the beta version, and if it is not installed, install it by using the command FVM install beta
And run the project:
fvm flutter run -d macos
Copy the code
build
fvm flutter build macos
Copy the code
For compiling desktop applications, be aware of building Windows applications on Windows, macOS applications on macOS, and Linux applications on Linux. Refer to the requirements of different platforms: flutter. Dev /desktop
Windows and Linux desktop applications are similar. Reference connection: flutter. Dev /desktop