Skip to content

Building Flutter apps

Hidenori Matsubayashi edited this page Jun 4, 2021 · 17 revisions

This page describes how to build Fluter apps.

1. Installing Flutter SDK

See also: Desktop support for Flutter

$ git clone https://github.com/flutter/flutter
$ sudo mv flutter /opt/
$ export PATH=$PATH:/opt/flutter/bin
$ flutter config --enable-linux-desktop
$ flutter doctor

Please note that you must use the same version (channel) that you built Flutter embedder for. I recommend that you use the latest version of the master channel for both the SDK and Flutter Engine. See also: Building Flutter Engine

2. Building Flutter apps

Here introduce how to build the flutter sample app.

Self-build

This is the method when the build machine and the target machine are the same. (x64 targets on x64 hosts / for Arm64 targets on Arm64 hosts)

Note that you need to build Flutter apps in the same mode(release/debug) libflutter_engine.so was built. It means you need to build Flutter apps in the release mode if you use libflutter_engine.so was built in release mode.

Build in release mode:

$ flutter create sample
$ cd sample/$ cd sample/
$ flutter build linux
$ cd ..

Build in debug mode:

$ flutter build linux --debug

If you want to work Flutter apps in debug mode, you can do the following steps on both x64 and arm64 hosts. In debug mode, the Flutter bundle artifacts are not architecturally different between x64 and arm64.

$ flutter build bundle --asset-dir=./bundle/data/flutter_assets
$ cp <path_to_flutter_sdk_install>/bin/cache/artifacts/engine/linux-*/icudtl.dat ./bundle/data

Cross-build (For Arm64 targets on x64 hosts)

Comming soon. We are contributing to support this now. See: https://github.com/flutter/flutter/issues/74929