Frontend  0.3.3
Loading...
Searching...
No Matches
Development

In this chapter, we set up a development environment that allows us to create the frontend, its unit tests, and the documentation. This means that we will primarily install the Flutter framework, as well as a few tools around it.

We recommend either an Arch (e.g. Garuda or Manjaro) or Ubuntu based distribution, so all of the following steps refer to those.

Prerequisites

In order to start developing the frontend, we need to meet quite a few prerequisites. Fortunately, most of them can be obtained directly from the package manager. But before we do that, let's bring our system up to date.

  • Arch
    sudo pacman -Syu --noconfirm
  • Ubuntu 24.04
    sudo apt update -y
    sudo apt upgrade -y

Without going into detail about each individual dependency, the most important ones are Flutter, a cross-platform app framework, Chromium, a web browser, Clang, a host compiler, CMake, a build system, Ninja, a build tool, Doxygen, a documentation generator, and Graphviz, a graph visualization software.

  • Arch
    sudo pacman -S --noconfirm chromium clang cmake doxygen git graphviz jdk-openjdk make ninja
  • Ubuntu 24.04
    sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
    sudo apt-get install -y chromium-browser clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev

Flutter

The Flutter framework is the only dependency that we cannot get directly from the (official) package manager. It's either available from AUR or from the flutter releases archive. The problem is that we need a very specific version, namely 3.27.4. This is the last version that supports the HTML renderer, which as of now simply produces a much smaller app than the newer canvaskit.

At the time of writing (06.03.2025), the gzipped app size is

  • 3.8MB with canvaskit
  • 1.1MB with HTML

Unless this changes drastically, the Flutter version must not be updated. However, Google promises improvement, the progress is tracked in an open issue on GitHub.

Warning
Packages from the package manager or AUR are not intended to be locked to a specific version. In case the installation from AUR no longer works, please fall back on the manual installation.
  • Arch
    git clone https://aur.archlinux.org/flutter-bin.git
    cd flutter-bin
    git checkout 9dd83f3012fb6b14f7a9453cdfbf2dd097053f79
    makepkg -si
  • Ubuntu 24.04

VSCode (optional)

We generally recommend VSCode for development. It has a great Dart/Flutter extension called dartcode which also provides excellent debug and testing support. Of course you are welcome to use any other IDE.

  • Arch
    sudo pamac install visual-studio-code-bin
  • Ubuntu 24.04
    snap install code --classic

Clone

The frontend source code is hosted on GitHub. We can use either SSH or HTTP to clone the repository. Using git clone without any additional arguments will clone the latest version of the master branch to the current working directory. After that, we can change into the Frontend directory we've just created.

  • SSH
    git clone git@github.com:OpenRemise/Frontend.git
    cd Frontend
  • HTTPS
    git clone https://github.com/OpenRemise/Frontend.git
    cd Frontend

Build

Normally, Flutter apps can be built directly from the command line, e.g.

flutter build linux

However, since we want to integrate the build into the Firmware, it will be wrapped in CMake. This allows us to use a Frontend target directly on the one hand, and on the other hand to have a FrontendRelease target that generates ready-made .zip archives for releases.

cmake --preset "Release"
cmake --build build --target FrontendRelease
Note
What CMake also does is deleting a bunch of unnecessary files, since the Flutter team unfortunately hasn't managed to clean up the builder folder properly yet...

Debug

With Flutter, we have to differentiate on which platform we want to debug.

Native

The easiest to debug are definitely native builds, as they provide us with a debugger with a start and stop function. The VSCode integration via dartcode is phenomenal and a simple click on debug configuration is (usually) enough to start a session.

These configurations can be found under .vscode/launch.json and look something like this.

{
"name": "Frontend (debug mode) OPENREMISE_FRONTEND_SMALL_SCREEN_WIDTH=800",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--dart-define",
"OPENREMISE_FRONTEND_SMALL_SCREEN_WIDTH=800"
]
}
Warning
If Flutter is complaining about Target of URI hasn't been generated you'll probably need to run the build runner with
dart run build_runner build --delete-conflicting-outputs

Web

No matter how good the native debuggers are, from time to time you need to debug directly in the browser. Flutter allows us to start directly in Chromium with the following call. There is no start or stop function, but the browser developer tools prove useful.

  • Fish
    . chromium.fish
    flutter run -d chrome --dart-define=OPENREMISE_FRONTEND_DOMAIN=remise.local --dart-define=OPENREMISE_FRONTEND_SMALL_SCREEN_WIDTH=800
  • Bash
    . chromium.sh
    flutter run -d chrome --dart-define=OPENREMISE_FRONTEND_DOMAIN=remise.local --dart-define=OPENREMISE_FRONTEND_SMALL_SCREEN_WIDTH=800

Test

Flutter as a modern framework integrates unit tests very tightly. All that is necessary to run the tests is a one-liner.

flutter test

Doc

If Doxygen was found during CMake's configuration phase, the FrontendDocs target can be built to create the documentation.

cmake --build build --target FrontendDocs