
Flutter App Development in Container
Table of Contents
Android development using flutter inside container
I am using
1. Get a Container Image.
$ podman pull docker.io/ubuntu
2. Create a Container
Volumes
- We need to configure our container to user Display screen of host.
Host's /tmp/.X11-unix map it to Container's /tmp/.X11-unix
- Next, adding volume for KVM, this is used to let emulator run inside a container.
Host's /dev/kvm map to Container's /dev/kvm
- Lastly, add a dir for file transfer between Host and Container.
Host's /home/dir/dir map to Container's /home/dir/dir
Variables
- For GUI apps to pop up in Host Screen
DISPLAY = :1
Attach the container
$ podman start flutty-flutter $ podman attach flutty-flutter
apt update && apt upgrade && apt install git nano wget gpg
3. Create a non root user. Refer to my blog here.
4. Install a text editor, by this we can test if Container can access the Display server of Host machine.
Install on Debian / Ubuntu (deb package):
Add the GPG key of the repository:
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg \
| gpg --dearmor \
| dd of=/usr/share/keyrings/vscodium-archive-keyring.gpg
Add the repository:
echo 'deb [ signed-by=/usr/share/keyrings/vscodium-archive-keyring.gpg ] https://download.vscodium.com/debs vscodium main' \
| tee /etc/apt/sources.list.d/vscodium.list
Update then install vscodium (if you want vscodium-insiders, then replace codium by codium-insiders):
apt update && apt install codium
5. Installing Flutter.
Download Flutter from https://docs.flutter.dev/get-started/install/linux.
Copy downloaded zip file to shared directory between Host and Container.
Extract he zip file to “/opt/” inside container.
$ tar -xf flutterfile.zipfile -C /opt/
Open .bashrc file of root user and add path to flutter.
$ nano ~/bashrc ## export PATH="$PATH:/opt/flutter/bin/"
Run
$ flutter doctor
You can ignore the warning about n ot using flutter in sudo mode.
- Disable the telemetry
$ flutter --disable-telemetry
6. Now use Flutter and Vscodium together.
Create Flutter app
$ flutter create newapp
cd into “newapp”
Open “newapp” in Vscodium
$ codium . You are trying to start VSCodium as a super user which isn't recommended. If this was intended, please add the argument `--no-sandbox` and specify an alternate user data directory using the `--user-data-dir` argument. root@840268e3177# codium --no-sandbox --user-data-dir .
Vscodium » Extenstions » Search for “Flutter” » Install (It will install Flutter and Dart).
Disable Dart’s Telemetry too
$ dart --disable-telemetry
7. If you want you can install a beautiful shell refer to my older post about zsh.
8. Install extenstions related to flutter in Vscodium
9. After installing Flutter you need to be able to install the apps into the emulator
The Android studio gives “Android” in /home/
So I copied the Android dir to this container’s /home/
Ran “flutter doctor” it suggested to to
flutter config --android-sdk add your path here "/home/Android/Sdk"
Then flutter suggested to go to sdbmanger and do
Run path/to/sdkmanager --install "cmdline-tools;latest"
Path to sdkmanager: /home/Android/Sdk/tools/bin/
Then sdkmanaget needs java to be installed
Install java
sudo apt install default-jdk