Flutter on Desktop



Flutter provides support for compiling a native Windows, macOS, or Linux desktop app. Flutter’s desktop support also extends to plugins—you can install existing plugins that support the Windows, macOS, or Linux platforms.

 

Requirements

To compile a desktop application, you must build it on the targeted platform: build a Windows application on Windows, a macOS application on macOS, and a Linux application on Linux. 


Additional macOS requirements

For macOS desktop development, you need the following in addition to the Flutter SDK:

 

Additional Windows requirements

For Windows desktop development, you need the following in addition to the Flutter SDK:

Visual Studio 2022 When installing Visual Studio, select the "Desktop development with C++" workload, including all of its default components, to install the necessary C++ toolchain and Windows SDK header files.

Set up

On Windows, desktop support is enabled on Flutter 2.10 or higher. On macOS and Linux, desktop support is enabled on Flutter 3 or higher.

You might run a flutter Doctor to see if there are any unresolved issues. You should see a checkmark for each successfully configured area. It should look something like the following on Windows, with an entry for "develop for Windows":

Flutter enable specific platform 


flutter config --enable-linux-desktop


flutter config --enable-macos-desktop


flutter config --enable-windows-desktop


Flutter disable specific platform 


flutter config --no-enable-linux-desktop


flutter config --no-enable-macos-desktop


flutter config --no-enable-windows-desktop


Add desktop support to an existing Flutter app

After enable and restart Vscode run command in your root directory


$ flutter create --platforms=windows,macos,linux


How to change Icon of the app


Add icons_launcher: ^2.0.2


Add config to pubspec.yaml or create a separate icons_launcher.yaml

icons_launcher:

  image_path: 'assets/icon.png'

  platforms:

    android:

      enable: true

    ios:

      enable: true

Run the package 

flutter pub get

flutter pub run icons_launcher:create

You can change icons_launcher file name

Example :

icons_launcher:

  image_path: 'assets/icon.png'

  platforms:

    android:

      enable: true

      image_path: 'assets/ic_logo_border.png'

      # adaptive_background_color: '#ffffff'

      adaptive_background_image: 'assets/ic_background.png'

      adaptive_foreground_image: 'assets/ic_foreground.png'

      adaptive_round_image: 'assets/ic_logo_round.png'

    ios:

      enable: true

      image_path: 'assets/ic_logo_rectangle.png'

    web:

      enable: true

      image_path: 'assets/ic_logo_border.png'

      favicon_path: 'assets/ic_logo_round.png'

    macos:

      enable: false

      image_path: 'assets/ic_logo_border.png'

    windows:

      enable: false

      image_path: 'assets/ic_logo_border.png'

    linux:

      enable: false

      image_path: 'assets/ic_logo_border.png'


Build a release app


flutter build windows

flutter build macos

flutter build linux









Comments

Popular posts from this blog

Flutter CI / CD

What is Dart-doc?