flat_buffers
25.9.23, released a year ago by an unverified publisher
FlatBuffers library for Dart to read and write binary data using generated code.
WASM-readyQuiet but busy
What it does
Provides a Dart implementation of the FlatBuffers serialization format. It includes a Builder for constructing buffers and generated classes for schema-defined data, enabling efficient cross‑language data exchange.
AI-written summary of version 25.9.23, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need high‑performance binary serialization compatible with other FlatBuffers implementations
- You want to share data structures between Dart and platforms like C++, Java, or JavaScript
Skip it when
- You only need simple JSON or text storage
- You require a pure Dart solution without a code‑generation step
Strengths
- Zero‑copy reads for fast deserialization
- Cross‑language compatibility with FlatBuffers ecosystem
- Supports custom buffer allocation and various optimizations
Weaknesses
- Requires running the flatc compiler to generate Dart code
- No built‑in higher‑level abstractions like ORM or JSON mapping
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 0
Install the flatc compiler for your platform and run it against your .fbs schema to generate Dart files; then add the generated files to your project.
import 'package:flat_buffers/flat_buffers.dart';
void main() {
final builder = Builder(initialSize: 1024);
// Example: write a string
final offset = builder.writeString('Hello FlatBuffers');
builder.finish(offset);
final bytes = builder.buffer;
// Read back
final bb = ByteData.sublistView(bytes);
final reader = ByteDataReader(bb);
final str = reader.readString(offset);
print(str);
}Works with
Packages commonly used together with flat_buffers: ones it builds on, ones built on it, and its own family.
- objectboxBuilt on flat_buffersFast on‑device NoSQL object database for Flutter and Dart native apps.
- flutter_sceneBuilt on flat_buffersA 3D game engine for Flutter built on Flutter GPU with PBR lighting and glTF support.
- flutter_map_tile_cachingBuilt on flat_buffersAdvanced caching and offline map region downloading for flutter_map.
- fast_rsaBuilt on flat_bufferslibrary for use RSA with support for android and ios, macOS, linux, windows and web
- open_meteoBuilt on flat_buffersA fully typed Dart SDK to access the Open-Meteo weather, air quality, and climate APIs.