Overview
Just getting interested on Flutter Desktop Embedding. as a 1st step, installing SDK and run example and quick code scan will be noted here. (hopefully this could be really 1st step tutorial for everyone)
Environment
- Ubuntu 16.04 (4.15.0-88-generic)
- Flutter SDK Master
- Flutter Desktop Embedding Master
Procedure
- Glone repo and Install SDK
just clone the repos from flutter project as below.
git clone git@github.com:flutter/flutter.git
git clone git@github.com:google/flutter-desktop-embedding.git
flutter binaries are store flutter/bin, make the path trough here as followings.
export PATH="<path to flutter repo>/flutter/bin:$PATH"
- Check dependent toolchain.
switch flutter mode into linux desktop
flutter config --enable-linux-desktop
then consult with flutter doctor, if everything is okay to go.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.15.21-pre.11, on Linux, locale ja_JP.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 26.0.2)
✗ Flutter requires Android SDK 28 and the Android BuildTools 28.0.3
To update using sdkmanager, run:
"/home/tomoyafujita/Android/Sdk/tools/bin/sdkmanager" "platforms;android-28" "build-tools;28.0.3"
or visit https://flutter.dev/setup/#android-setup for detailed instructions.
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed
instructions.
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (version 2.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.43.0)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
I believe that Android toolchain and Android Studio are not required to develop linux desktop application, so that we can ignore the warnings.
- Run example application
flutter config --enable-linux-desktop/example
flutter run
Launching lib/main.dart on Linux in debug mode...
Building Linux application...
Flutter is taking longer than expected to report its views. Still trying...
Syncing files to device Linux... 1,376ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
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).
An Observatory debugger and profiler on Linux is available at: http://127.0.0.1:38875/DBy1Vv9Qb38=/
Statistics for VM
name vm@ws://127.0.0.1:38875/DBy1Vv9Qb38=/ws
version 2.8.0-dev.13.0.flutter-684c53a6f1 (Wed Mar 11 15:41:59 2020 +0000) on "linux_x64"
embedder Flutter
started at 2020-03-16 22:11:48.876
uptime 0:01:09.529000
refreshed at 2020-03-16 22:12:58.406
pid 8473
peak memory 151.5MB
current memory 147.7MB
native zone memory 0B
native heap memory unavailable
native heap allocation count unavailable
sudo netstat -panda| grep 38875
tcp 0 0 127.0.0.1:38875 0.0.0.0:* LISTEN 8473/flutter_deskto
tcp 0 0 127.0.0.1:60032 127.0.0.1:38875 ESTABLISHED 8234/dart
tcp 0 0 127.0.0.1:38875 127.0.0.1:60032 ESTABLISHED 8473/flutter_deskto
-> application pid is 8473, and dart vm is 8234. dart is connected with application via TCP, and application listens on the port to get activity effectively on the screen.
pmap -x 8473
8473: /home/tomoyafujita/DVT/flutter/flutter-desktop-embedding/example/build/linux/debug/flutter_desktop_example
Address Kbytes RSS Dirty Mode Mapping
0000000000400000 64 16 0 r-x-- flutter_desktop_example
0000000000400000 0 0 0 r-x-- flutter_desktop_example
000000000060f000 4 4 4 r---- flutter_desktop_example
...
ffffffffff600000 0 0 0 r-x-- [ anon ]
---------------- ------- ------- -------
total kB 1222876 148804 124272
-> physical memory consumption is almost 150MB for this example.
pidstat -p 8473 1
Linux 4.15.0-88-generic (tomoyafujita-Inspiron-620s) 2020年03月16日 _x86_64_ (4 CPU)
22時19分28秒 UID PID %usr %system %guest %CPU CPU Command
22時19分29秒 1000 8473 0.00 0.00 0.00 0.00 1 flutter_desktop
22時19分30秒 1000 8473 0.00 0.00 0.00 0.00 1 flutter_desktop
22時19分31秒 1000 8473 0.00 0.00 0.00 0.00 1 flutter_desktop
22時19分32秒 1000 8473 0.00 0.00 0.00 0.00 1 flutter_desktop
22時19分33秒 1000 8473 0.00 0.00 0.00 0.00 1 flutter_desktop
22時19分34秒 1000 8473 0.00 0.00 0.00 0.00 1 flutter_desktop
22時19分35秒 1000 8473 3.00 0.00 0.00 3.00 2 flutter_desktop
22時19分36秒 1000 8473 10.00 1.00 0.00 11.00 2 flutter_desktop
22時19分37秒 1000 8473 17.00 1.00 0.00 18.00 0 flutter_desktop
22時19分38秒 1000 8473 8.00 0.00 0.00 8.00 1 flutter_desktop
22時19分39秒 1000 8473 16.00 1.00 0.00 17.00 3 flutter_desktop
22時19分40秒 1000 8473 4.00 0.00 0.00 4.00 2 flutter_desktop
22時19分41秒 1000 8473 0.00 0.00 0.00 0.00 2 flutter_desktop
22時19分42秒 1000 8473 2.00 0.00 0.00 2.00 2 flutter_desktop
22時19分43秒 1000 8473 0.00 0.00 0.00 0.00 2 flutter_desktop
22時19分44秒 1000 8473 0.00 0.00 0.00 0.00 2 flutter_desktop
22時19分45秒 1000 8473 0.00 0.00 0.00 0.00 3 flutter_desktop
...
-> confirmed that dart does not affect any activity without any input, but once input comes in, it will consume close to 20% of user.
Example Source Code
This example is actually sample of materials.
not a big deal, but plugin should be something more important for desktop environemtn to connect x11 serser.
Reference
What's next?
- Flutter System Framework and Architecture Deep Dive
- Deep dive into desktop plugin