1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

flutterをlinuxで使う

Posted at

flutterをlinuxで使ってみたときの記録です。以下を参考にさせていただいています。

前提

  • OS: Ubuntu 20.04

手順

クローンします。

$ git clone git@github.com:flutter/flutter.git

パスを通します。

$ sudo mv flutter /usr/local
$ export PATH=$PATH:/usr/local/flutter/bin

linux側の必要なライブラリをアップデート、インストールします。

$ sudo apt-get update
$ sudo apt install clang curl pkg-config ninja-build cmake libgtk-3-dev libblkid-dev liblzma-dev unzip

これで linux-desktopでも使えるようにします。

$ flutter config --enable-linux-desktop


╔════════════════════════════════════════════════════════════════════════════╗
  ║                 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 doctorでうまくいくか確認します。Androidは入れていないのですが、参考記事をみたら入れれそうです。

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.5.0-7.0.pre.105, on Ubuntu 20.04.2 LTS
    5.11.0-25-generic, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for
      more details.
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version 1.54.3)
[✓] Connected device (2 available)

プロジェクト作成

$ mkdir fluttersample
$ cd fluttersample
$ flutter create .
===============
Running "flutter pub get" in fluttersample...                       3.4s
Wrote 87 files.
All done!
In order to run your application, type:
  $ cd .
  $ flutter run
Your application code is in ./lib/main.dart.

最後のメッセージの通りにflutter runすると、linuxかchromeか選ぶので、linuxを選びます。
以下のコマンドでも大丈夫です。

flutter run -d linux

以下のようなlinux desktop用のデモアプリが立ち上がります。

Screenshot from 2021-08-18 01-41-53.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?