Package selection guidance compiled from public package information, community data, and project usage.
A portable Dart package for efficient data serialization and deserialization, featuring a dynamic BytesBuffer for low-level reading and writing of binary data. Designed to streamline the conversion between objects and serialized formats, it supports cross-platform use across Android, iOS, Web, macOS, Windows, and Linux. Ideal for applications requiring high-performance data handling with minimal overhead. The package is particularly useful in scenarios involving network communication, file storage, or real-time data exchange where speed and reliability are critical.
Use cases
Binary data transmission
File format parsing
Real-time data processing
Cross-platform data sharing
Network protocol implementation
Key features
Dynamic BytesBuffer
Efficient serialization
Cross-platform support
Low-level data manipulation
High performance
Suitable for
High-performance apps
Network-heavy applications
Embedded systems
Data-intensive workflows
Custom binary formats
Considerations
Requires understanding of binary data
Limited to basic types without custom logic
Not ideal for complex JSON structures
Manual type management needed
Learning curve for low-level operations
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
data_serializer
Portable Dart package to handle data serialization/deserialization efficiently,
including a dynamic BytesBuffer to read/write data.
API Documentation
See the API Documentation for a full list of functions, classes and extension.
Usage
import'package:data_serializer/data_serializer.dart';
voidmain() {
// Dynamic bytes buffer with initial capacity of 16 bytes.var buffer = BytesBuffer(16);
// Write a unsigned int of 32 bits:
buffer.writeInt32(0x10203040);
// Write a `String` encoded using UTF-8:
buffer.writeString('Hello!');
// Write a unsigned int of 64 bits:
buffer.writeUint64(9223372036854775807);
// Write a data block (prefixed by 4 bytes for he data length).var dataBlock = [110, 120, 130, 140, 150, 160].toUint8List();
buffer.writeBlock32(dataBlock);
// Write all bytes:
buffer.writeAll([210, 220]);
// The current length of the buffer, expanded automatically:print('length: ${buffer.length}');
// Change the current position cursor to `0`:
buffer.seek(0);
// Read a 32 bits int:var n32 = buffer.readUint32();
print('n32: 0x${n32.toHex32()}');
// Reads a `String` decoding from UTF-8:var s = buffer.readString();
print('s: $s');
// Read a 64 bits int:var n64 = buffer.readUint64();
print('n64: $n64');
// The current buffer position:print('position: ${buffer.position}');
// Read a data block:var dataBlock2 = buffer.readBlock32();
print('dataBlock2: $dataBlock2');
// The position after read the data block:print('position: ${buffer.position}');
// The remaining bytes in the buffer:var tailBytes = buffer.readRemainingBytes();
print('tailBytes: $tailBytes');
}
All the operations are tested to be compatible with JavaScript.
Note that JS only supports 53-bits integers. To avoid any issue serializing 64-bits integers,
try to use BigInt serialization, or ensure that you are bellow the 53-bits range.
See the class DataSerializerPlatform if you need runtime information
about integers support.
Test Coverage
This package aims to always have a high test coverage percentage, over 95%.
With that the package can be a reliable tool to support your important projects.