Skip to content

Building Flutter apps

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

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 embedder

Building Flutter apps

Here introduce how to build the flutter sample app.

For 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 for release mode:

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

Build for debug mode:

$ flutter build linux --debug

For Arm64 targets on x64 hosts

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

FYI: only in debug mode

If you want to work Flutter apps in debug mode, you can also 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