Build Flutter App for Embedded Linux
Flutter SDK
git clone https://github.com/sony/flutter-elinux.git
sudo mv flutter-elinux /opt/
export PATH=$PATH:/opt/flutter-elinux/bin:/opt/flutter-elinux/flutter/bin
Create Flutter Example Hello World
. /opt/poky/4.0.15/environment-setup-cortexa53-crypto-poky-linux
flutter-elinux create helloworld
cd helloworld
flutter-elinux build elinux --debug --target-arch=arm64 \
--target-compiler-triple=aarch64-poky-linux \
--target-sysroot=/opt/poky/4.0.15/sysroots/cortexa53-crypto-poky-linux
file build/elinux/arm64/debug/bundle/helloworld
build/elinux/arm64/debug/bundle/helloworld: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.14.0, with debug_info, not stripped
Enable Flutter Custom Devices
$HOME/.flutter_custom_devices.json
{
"custom-devices": [
{
"id": "roc-rk3328-cc",
"label": "ROC-RK3328-CC",
"sdkNameAndVersion": "yocto with flutter",
"enabled": true,
"platform": "arm64",
"backend": "wayland",
"ping": [
"ping",
"-c",
"1",
"-w",
"1",
"192.168.1.82"
],
"pingSuccessRegex": "ttl=",
"postBuild": null,
"install": [
"scp",
"-r",
"-o",
"BatchMode=yes",
"${localPath}",
"root@192.168.1.82:/tmp/${appName}"
],
"uninstall": [
"ssh",
"-o",
"BatchMode=yes",
"root@192.168.1.82",
"rm -rf \"/tmp/${appName}\""
],
"runDebug": [
"ssh",
"-o",
"BatchMode=yes",
"root@192.168.1.82",
"export XDG_RUNTIME_DIR=/run/user/1001; /tmp/${appName}/${appName} -b ."
],
"stopApp": [
"ssh", "root@192.168.1.82",
"ps aux | grep \"/tmp/${appName}\" | grep -v grep | awk '{print $2}' | xargs kill"
],
"forwardPort": [
"ssh",
"-o",
"BatchMode=yes",
"-o",
"ExitOnForwardFailure=yes",
"-L",
"127.0.0.1:${hostPort}:127.0.0.1:${devicePort}",
"root@192.168.1.82",
"echo 'Port forwarding success'; read"
],
"forwardPortSuccessRegex": "Port forwarding success",
"screenshot": null
}
]
}
flutter-elinux devices
5 connected devices:
Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.3 LTS 6.5.0-21-generic
eLinux (desktop) • elinux-wayland • flutter-tester • Ubuntu 22.04.3 LTS 6.5.0-21-generic
eLinux (desktop) • elinux-x11 • flutter-tester • Ubuntu 22.04.3 LTS 6.5.0-21-generic
eLinux (mobile) • roc-rk3328-cc • flutter-tester • yocto with flutter
Remote Debugging
flutter-elinux run -d roc-rk3328-cc
Launching lib/main.dart on eLinux in debug mode...
Uninstall helloworld from roc-rk3328-cc.
Uninstallation Success
Install helloworld (build/elinux/arm64/debug/bundle) to roc-rk3328-cc
Installation Success
Launch helloworld.name on roc-rk3328-cc
Syncing files to device eLinux... 114ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on eLinux is available at: http://127.0.0.1:37679/mwcEpXRwu80=/
The Flutter DevTools debugger and profiler on eLinux is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:37679/mwcEpXRwu80=/
Type h
for all available commands, type v
to open flutter devtools.
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
v Open Flutter DevTools.
w Dump widget hierarchy to the console. (debugDumpApp)
t Dump rendering tree to the console. (debugDumpRenderTree)
L Dump layer tree to the console. (debugDumpLayerTree)
f Dump focus tree to the console. (debugDumpFocusTree)
S Dump accessibility tree in traversal order. (debugDumpSemantics)
U Dump accessibility tree in inverse hit test order. (debugDumpSemantics)
i Toggle widget inspector. (WidgetsApp.showWidgetInspectorOverride)
p Toggle the display of construction lines. (debugPaintSizeEnabled)
I Toggle oversized image inversion. (debugInvertOversizedImages)
o Simulate different operating systems. (defaultTargetPlatform)
b Toggle platform brightness (dark and light mode). (debugBrightnessOverride)
P Toggle performance overlay. (WidgetsApp.showPerformanceOverlay)
a Toggle timeline events for all widget build methods. (debugProfileWidgetBuilds)
M Write SkSL shaders to a unique file in the project directory.
g Run source code generators.
j Dump frame raster stats for the current frame. (Unsupported for web)
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on eLinux is available at: http://127.0.0.1:43639/dIT2DPYXz8I=/
The Flutter DevTools debugger and profiler on eLinux is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:37679/mwcEpXRwu80=/
Launching Flutter DevTools for eLinux at http://127.0.0.1:9100?uri=http%3A%2F%2F127.0.0.1%3A37679%2F%mwcEpXRwu803D%2F