タイトル : Flutterをやってみよう
更新日 : 2023-02-05
カテゴリ : プログラミング
インストール
- Ubuntuにインストール Linux install
-
System requirementsはOK
libGLU.so.1 - provided by mesa packages such as libglu1-mesa on Ubuntu/Debian and mesa-libGLU on Fedora.
libglu1-mesa/focal,now 9.0.1-1build1 amd64 [インストール済み、自動] が入っていることを確認した
-
snap で
-
$ sudo snap install flutter --classic
[sudo] xxx のパスワード:
flutter 0+git.ccbc698 from Flutter Team? installed
$
- flutterを最初に使う時に Initializing Flutter がかかる
$ flutter --version
Initializing Flutter
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 172k 100 172k 0 0 705k 0 --:--:-- --:--:-- --:--:-- 705k
Downloading https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.7.1-stable.tar.xz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 536M 100 536M 0 0 5102k 0 0:01:47 0:01:47 --:--:-- 5413k
Flutter initialized
Flutter 3.7.1 ? channel stable ? https://github.com/flutter/flutter.git
Framework ? revision 7048ed95a5 (3 days ago) ? 2023-02-01 09:07:31 -0800
Engine ? revision 800594f1f4
Tools ? Dart 2.19.1 ? DevTools 2.20.1
??????????????????????????????????????????????????????????????????????????????
? Welcome to Flutter! - https://flutter.dev ?
? ?
? The Flutter tool uses Google Analytics to anonymously report feature usage ?
? statistics and basic crash reports. This data is used to help improve ?
? Flutter tools over time. ?
? ?
? Flutter tool analytics are not sent on the very first run. To disable ?
? reporting, type 'flutter config --no-analytics'. To display the current ?
? setting, type 'flutter config'. If you opt out of analytics, an opt-out ?
? event will be sent, and then no further information will be sent by the ?
? Flutter tool. ?
? ?
? By downloading the Flutter SDK, you agree to the Google Terms of Service. ?
? Note: The Google Privacy Policy describes how data is handled in this ?
? service. ?
? ?
? Moreover, Flutter includes the Dart SDK, which may send usage metrics and ?
? crash reports to Google. ?
? ?
? Read about data we send with crash reports: ?
? https://flutter.dev/docs/reference/crash-reporting ?
? ?
? See Google's privacy policy: ?
? https://policies.google.com/privacy ?
??????????????????????????????????????????????????????????????????????????????
Flutter 3.7.1 ? channel stable ? https://github.com/flutter/flutter.git
Framework ? revision 7048ed95a5 (3 days ago) ? 2023-02-01 09:07:31 -0800
Engine ? revision 800594f1f4
Tools ? Dart 2.19.1 ? DevTools 2.20.1
$
- flutter doctor とりあえずAndroidの設定なし、Android Studioは使わない。(Windows上でVisual Studio Codeでdartを書く)
$ flutter doctor
Running "flutter pub get" in flutter_tools...
Resolving dependencies in ../../../snap/flutter/common/flutter/packages/flutter_tools... (9.8s)
_fe_analyzer_shared 50.0.0 (52.0.0 available)
analyzer 5.2.0 (5.4.0 available)
archive 3.3.2 (3.3.6 available)
args 2.3.1 (2.3.2 available)
built_value 8.4.2 (8.4.3 available)
checked_yaml 2.0.1 (2.0.2 available)
collection 1.17.0 (1.17.1 available)
completion 1.0.0 (1.0.1 available)
coverage 1.6.1 (1.6.2 available)
dds 2.5.0 (2.7.4 available)
dds_service_extensions 1.3.1 (1.3.2 available)
devtools_shared 2.18.0 (2.20.1 available)
dwds 16.0.2 (17.0.0 available)
fixnum 1.0.1 (1.1.0 available)
frontend_server_client 3.1.0 (3.2.0 available)
intl 0.17.0 (0.18.0 available)
io 1.0.3 (1.0.4 available)
js 0.6.5 (0.6.7 available)
json_annotation 4.7.0 (4.8.0 available)
logging 1.1.0 (1.1.1 available)
matcher 0.12.13 (0.12.14 available)
meta 1.8.0 (1.9.0 available)
mime 1.0.2 (1.0.4 available)
multicast_dns 0.3.2+2 (0.3.2+3 available)
native_stack_traces 0.5.2 (0.5.5 available)
path 1.8.2 (1.8.3 available)
sse 4.1.1 (4.1.2 available)
test 1.22.0 (1.22.2 available)
test_api 0.4.16 (0.4.18 available)
test_core 0.4.20 (0.4.22 available)
vm_service 9.4.0 (10.1.2 available)
web_socket_channel 2.2.0 (2.3.0 available)
webdriver 3.0.1 (3.0.2 available)
Got dependencies in ../../../snap/flutter/common/flutter/packages/flutter_tools!
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, 3.7.1, on Ubuntu 20.04.5 LTS 5.15.0-56-generic, locale ja_JP.UTF-8)
[?] Android toolchain - develop for Android devices
? Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[?] Chrome - develop for the web
[?] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[?] Connected device (2 available)
[?] HTTP Host Availability
! Doctor found issues in 2 categories.
$
やってみる
-
プロジェクトの作成
lib/main.dartがメインなのですね
$ flutter create helloworld1
Creating project helloworld1...
Running "flutter pub get" in helloworld1...
Resolving dependencies in helloworld1... (1.3s)
+ async 2.10.0
+ boolean_selector 2.1.1
+ characters 1.2.1
+ clock 1.1.1
+ collection 1.17.0 (1.17.1 available)
+ cupertino_icons 1.0.5
+ fake_async 1.3.1
+ flutter 0.0.0 from sdk flutter
+ flutter_lints 2.0.1
+ flutter_test 0.0.0 from sdk flutter
+ js 0.6.5 (0.6.7 available)
+ lints 2.0.1
+ matcher 0.12.13 (0.12.14 available)
+ material_color_utilities 0.2.0
+ meta 1.8.0 (1.9.0 available)
+ path 1.8.2 (1.8.3 available)
+ sky_engine 0.0.99 from sdk flutter
+ source_span 1.9.1
+ stack_trace 1.11.0
+ stream_channel 2.1.1
+ string_scanner 1.2.0
+ term_glyph 1.2.1
+ test_api 0.4.16 (0.4.18 available)
+ vector_math 2.1.4
Changed 24 dependencies in helloworld1!
Wrote 127 files.
All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd helloworld1
$ flutter run
Your application code is in helloworld1/lib/main.dart.
$
- 起動 flutter run
Linuxのアプリか、Chromeかを選べるんだ。 rでHot reloadでRでHot restartなんですね
以下で他のマシンからも行ける。すごいですね。
flutter run -d web-server --web-hostname=0.0.0.0 --web-port=8086
$ flutter run
Multiple devices found:
Linux (desktop) ? linux ? linux-x64 ? Ubuntu 20.04.5 LTS 5.15.0-56-generic
Chrome (web) ? chrome ? web-javascript ? Google Chrome 109.0.5414.119
[1]: Linux (linux)
[2]: Chrome (chrome)
Please choose one (To quit, press "q/Q"): 1
Launching lib/main.dart on Linux in debug mode...
Building Linux application...
** (helloworld1:27550): CRITICAL **: 22:56:52.624: Failed to read XDG desktop portal settings:
GDBus.Error:org.freedesktop.portal.Error.NotFound: Requested setting not found
** (helloworld1:27550): CRITICAL **: 22:56:52.627: Failed to read XDG desktop portal settings:
GDBus.Error:org.freedesktop.portal.Error.NotFound: Requested setting not found
Syncing files to device Linux... 139ms
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).
- とりあえず lib/main.dartを少し書き替えてみて(日本語に直して、赤い丸を書いてみた)、どんな感じがざっくりとみてみました。