Skip to content
pubscout

dart_periphery

0.9.21, released 5 days ago by flutterdev.at

Dart FFI bindings for Linux peripheral I/O (GPIO, I2C, SPI, etc.).

$ flutter pub add dart_periphery
Source repository

What it does

Provides Dart wrappers around the c‑periphery library to control hardware peripherals on Linux platforms. It exposes classes for GPIO, LED, PWM, SPI, I2C, MMIO, ADC and serial communication via FFI.

AI-written summary of version 0.9.20, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need direct access to Linux GPIO, I2C, SPI, PWM, or serial ports from Dart code
  • Running on a Raspberry Pi or similar SBC and want a Dart‑native API instead of shell commands

Skip it when

  • Your app must run on non‑Linux platforms (Windows, macOS, web)
  • You prefer a pure‑Dart implementation without native dependencies

Strengths

  • Thin, close mapping to the well‑tested c‑periphery library
  • Supports a wide range of peripheral interfaces
  • Works on popular SBCs like Raspberry Pi, NanoPi, Banana Pi

Weaknesses

  • Linux‑only; cannot be used on other OSes
  • Requires native library and proper permissions to access /dev devices
  • Setup can be tricky for beginners unfamiliar with FFI

Setup

Kind
FFI (native library)
Effort
Medium
Code generation
No
Direct dependencies
8

Add the package, ensure the c‑periphery shared library is available on the target device, and grant appropriate permissions to access /dev/* devices (e.g., run as root or adjust udev rules).

import 'package:dart_periphery/dart_periphery.dart';

void main() {
  var gpio = GPIO(18, GPIOdirection.gpioDirOut);
  gpio.write(true);
  gpio.dispose();
}

Alternatives

Packages that do the same job and could replace dart_periphery.

  • posix

    Provides low‑level POSIX system calls for Linux but lacks the high‑level peripheral abstractions of dart_periphery

Works with

Packages commonly used together with dart_periphery: ones it builds on, ones built on it, and its own family.