Skip to content
pubscout

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
$ flutter pub add flat_buffers
Source repository

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.