Flutter 3 on Devuan 4: Getting started
Tags: flutter, dart, mobile, devuan
Published: 2023-08-02 12:20:16

## Summary

[Flutter](https://flutter.dev/) is one of the mobile app frameworks developed by [Google](https://www.google.com/) which supports both [Android](https://www.android.com/) and [iOS](https://www.apple.com/ios/). It is cross-platform and being advanced to be applied to other platforms. Their official website says:

> Flutter transforms the app development process. Build, test, and deploy beautiful mobile, web, desktop, and embedded apps from a single codebase.

On May 12, 2022, its latest major version, [3](https://docs.flutter.dev/development/tools/sdk/release-notes/release-notes-3.0.0) was released.

I built the dev env on [Devuan](https://www.debian.org/) [GNU](https://www.gnu.org/)+[Linux](https://kernel.org/), a fork of [Debian](https://www.debian.org/) without [systemd](https://www.freedesktop.org/wiki/Software/systemd/). It resembles [my past trial on Artix Linux](https://scqr.net/en/blog/2023/01/02/flutter-3-on-arch-linux-getting-started/index.html).

This post shows how I did it.
It is manual installation without Debian package management system (`apt-get` etc.). However, it isn't complicated thanks to the officially distributed packages.

### Environment

- OS: Devuan 4 (Chimaera)
- App Framework: Flutter 3
- Programming Language: [Dart](https://dart.dev/)
- IDE: [Android Studio](https://developer.android.com/studio/) 2022.3.1.18

## Tutorial

All [`doas`](https://wiki.archlinux.org/title/Doas) from [OpenBSD's](https://man.openbsd.org/doas) can be replaced with [`sudo`](https://wiki.archlinux.org/title/Sudo).

### Get Android Studio (IDE)

Install it and configure. [This post](https://scqr.net/en/blog/2023/07/31/android-studio-on-devuan-4-getting-started/index.html) may be helpful.

### Install dependencies

Run:

```console
$ doas apt install cmake clang ninja-build libgtk-3-dev
```

### Get Flutter and Dart SDK

#### Flutter

Get the `.tar.xz` package in ["Install Flutter manually"](https://docs.flutter.dev/get-started/install/linux#install-flutter-manually) in the official docs.

![flutter-package-officially-distributed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nnx75d9twhvt3fi2jz1w.png)

Then run to extract:

```console
$ tar xJf flutter_linux_3.xx.xx-stable.tar.xz
```

#### Dart SDK

Get the `.zip` package in ["Stable channel"](https://dart.dev/get-dart/archive#stable-channel) in "Dart SDK archive" in the official.

![dart-sdk-package-officially-distributed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ezur1yqyp0ds9rkvwy2y.png)

Then extract all from it.

### Set up `PATH` environment variable

Update `PATH` to let them available in IDE:

```console
$ export PATH=(readlink -f dart-sdk/bin):"$PATH"
$ export PATH=(readlink -f flutter/bin):"$PATH"
```

The order above is important: First `dart-sdk` comes and then `flutter` does. It means we should be careful that flutter should be resolved earlier than dart.
Otherwise, you will meet the warning from `flutter doctor`:

```
! Warning: `dart` on your path resolves to
  /(...)/dart-sdk/bin/dart, which is not inside your current
  Flutter SDK checkout at /(...)/flutter. Consider adding
  /(...)/flutter/bin to the front of your path.
```

#### How to update `PATH` at login (Optional)

Well, it should be useful to add them to `PATH` environment variable at login.
It's done, for example, by editing `~/.profile`.

```sh
export PATH="$HOME/(...)/dart-sdk/bin:$PATH"
export PATH="$HOME/(...)/flutter/bin:$PATH"
```

In addition, with multiple variables to be added, a list as below and for-loop statement are also available.

```sh
for x in \
    $HOME/(...)/(something to be added) \
    $HOME/(...)/dart-sdk \
    $HOME/(...)/flutter
do
    if [ -d "$x" ] ; then
        PATH="$x/bin:$PATH"
    fi
done
```

### Set up `CHROME_EXECUTABLE` in case of Chromium used (Optional)

In order to pass tests by `flutter doctor` perfectly, you must have either Google Chrome or defined `CHROME_EXECUTABLE`.
[Chromium](https://www.chromium.org/Home/) was my choice and thus I ran:

```console
$ export CHROME_EXECUTABLE=/usr/bin/chromium
```

### Configure IDE

Open "Settings" in "File" in the top menus and choose "Plugins".

Install "Flutter" and "Dart".

![ide-setup-flutter-dart-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/embm8lntjof0ndvip7gf.png)

You will see warning on Flutter. It has to be accepted:

![ide-setup-flutter-dart-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yyren6cf4mehy2gp41yv.png)

After Flutter plugin installed, you will be required to "Restart" IDE.

![ide-setup-flutter-dart-03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46vdeo3b8ulohigo9f76.png)

Next, we have to install Android SDK Command-line Tools.

Open "Settings" again and go to "Languages & Frameworks" > "Android SDK" > "SDK Tools".
Check "Android SDK Command-line Tools (latest)" and click "OK"s.

![ide-setup-flutter-dart-04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jpf2z9g5op6zbyk2wnwx.png)

![ide-setup-flutter-dart-05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6bwxxtv1nz1p16x8rah.png)

The download will begin and finish after a while:

![ide-setup-flutter-dart-06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvq9k84flhornf5yzaqg.png)

### Run `flutter doctor`

You have two tasks left: Agree to the Android licenses, and validate your environment.

They are done by `flutter doctor`, one of the [`flutter` commands](https://docs.flutter.dev/reference/flutter-cli#flutter-commands).
Open terminal and run to deal with the first task:

```console
$ flutter doctor --android-licenses
```

You will be asked if agree to each of them.

Next, run to validate:

```console
$ flutter doctor
```

Printed out as below ?

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on Devuan GNU/Linux 4 (chimaera) 5.10.0-23-amd64, locale
    en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.3)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
```

Congratulations 🎉🎉

#### Opt out telemetry by Flutter (Optional)

Additionally, if you want to opt it out, run:

```console
$ flutter --disable-telemetry
Analytics reporting disabled.
```

### Create a Flutter project

Now we are ready. Let's create your first project !!

Start Android Studio and click "New Flutter Project".

![flutter-project-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6j8riho7ugfzif2w7s72.png)

After validating the paths of flutter and dart, click "Next":

![flutter-project-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hloc4qmx9u3dqam7m6u1.png)

![flutter-project-03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47hjr7y5qfrkfoki9z8q.png)

Enter and confirm the project information, and click "Create":

![flutter-project-04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4ees8rinbxkg28b3z4v.png)

After a little short, the creation will be completed.

![flutter-project-05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ympkvn6rgigym15jam6.png)

Shall we run the default demo ? Start the virtual device in "Device Manager":

![flutter-project-06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3y5oxm22viadop7j6cfx.png)

Then run the app by clicking the green triangle button at a little right to the center in the second-top bar.
Alternatively, push Shift + F10, or click [Run] - [Run 'app'] in the top menus.

![flutter-project-07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24zbgp6slczghuso3oe4.png)

Your flutter app is here !!

#### Editing examples

The below is a small trial to customize it: Changed the title phrase and also color theme. (Line 31, 34)

![flutter-project-08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gogijgfwdxaxpnljun34.png)

#### Build executable for Android mobile

Here is another small trial. You can build APK or App Bundle:

![flutter-project-09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzftwmj7xd0gblyqnr8o.png)

...and deliver it easily ;)

![flutter-project-10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snq2uwffcj1yzzmlgj6t.png)

## Conclusion

You got ready to develop Flutter apps. I hope you enjoy the cross-platform development 💫

Besides, there may be other ways to install them, although there doesn't seem no such [Flatpak](https://flatpak.org/) packages in [Flathub](https://flathub.org/). For example, some scenario to use some release channel or [Docker](https://www.docker.com/) / [Podman](https://podman.io/). Additionally, when you use a different Linux distro where systemd is adopted and therefore can do [Snaps](https://snapcraft.io/) (Snapd), you have another possibility.

🎶 🎵 🎸 Happy development 🥁 🎶 🎵