dart_periphery
0.9.21, released 5 days ago by flutterdev.at
Dart FFI bindings for Linux peripheral I/O (GPIO, I2C, SPI, etc.).
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.
Works with
Packages commonly used together with dart_periphery: ones it builds on, ones built on it, and its own family.
- archivedart_periphery depends on itEncodes and decodes archive and compression formats such as zip, tar, gzip, and zlib.
- stack_tracedart_periphery depends on itProvides parsing, inspection, and readable formatting of Dart stack traces.
- asyncdart_periphery depends on itUtility classes and helpers that extend Dart's async library.
- ffidart_periphery depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- processdart_periphery depends on itPluggable, mockable process invocation abstraction for Dart.