Skip to content

nerves-flutter/nerves_flutter_support

Repository files navigation

nerves_flutter_support

Static Badge

⚠️ NOTE: This is a fairly new project. Functionally everything is working on tested Nerves systems.

What Is This?

NervesFlutterSupport is the base library for running Flutter based UI applications on Nerves devices.

Overview

NervesFlutterSupport contains the following components:

  • Pre-compiled and patched runtime libraries for various dependencies. (See builder/ for more info.)
  • A Mix Release Step that can be included in your existing Mix project.
    • Takes care of downloading the Flutter embedder and runtime libraries.
    • Will automatically compile your Flutter project using the gen_snapshot tool and output an AOT build.
  • NervesFlutterSupport.Flutter.Engine - A module to create a Muontrap child_spec for running the embedder.
  • NervesFlutterSupport.Udev - (Automatically started for you) A module that ensure eudevd is running for input devices to function properly.

Tested Platforms

NervesFlutterSupport has been tested on the following platforms:

  • Raspberry Pi 4
  • Raspberry Pi 5

However it should be noted that any aarch64 based Nerves System should be compatible with this library.

Please file any issues if you run into any problems with your ARM64 platform. We also welcome Buildroot config contributions for other platforms.

Getting Started

Currently we only support Linux and macOS hosts when building firmware. Windows users should use WSL.

If you are a macOS user, please ensure you have docker installed!

  1. Install Flutter. See the top of this readme file for which version to use. (Flutter versions may change with Hex package versions!)
  2. Create a new Flutter app in your Mix project using: flutter create flutter_app.
  3. Add this package to your deps in mix.exs.
  4. Add the release step to your existing firmware's steps: member:
  steps: [
    &Nerves.Release.init/1,
    &NervesFlutterSupport.BuildFlutterApp.run/1, # Add Me!
    :assemble
  ],
  1. Run mix firmware as you normally would, if all is well, you should see you Flutter app build and emit a bundle into your priv/ directory.
  2. To run the Flutter app you can add the following to your Application or Supervisor children:
# With no options, your Flutter app bundle is expreted to be in `priv/flutter_app`
NervesFlutterSupport.Flutter.Engine.create_child(
  app_name: :my_flutter_app,
)

Example Project

Example Project: NervesFlutterExample

NervesFlutterExample is a basic Flutter + Nerves firmware for :rpi4 and :rpi5 targets. It uses gRPC and Protobufs to communicate between the Nerves firmware code and the Dart Flutter application.