data_serializer
Portable Dart package to handle data serialization/deserialization efficiently, including a dynamic BytesBuffer to read/write data.
1.2.3
6.0K downloads/mo
#3598 most downloaded on pub.dev
gmpassos/data_serializer
What this package is like to depend on
Last release 9 days ago
15 Aug 2026
Release timing varies
gaps range from 8 days to 1.7 years
Nearly every release is documented
notes for 18 of 18 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
18 releases · first in 2022
2 releases in the last 12 months
see the full history below
Release timeline
18 releases · Jan 2022 to Aug 2026Releases
latest 18-
1.2.315 Aug 2026Release notes
Open source →Four correctness fixes. The first affects every platform; the other three are
web-only (dart2js/dartdevc), where anintis a JavaScript double and the
bitwise operators are 32-bit.-
DataSerializerPlatformGeneric(web):- Fixed
shiftLeftIntandshiftRightIntfor non-negative operands.
Both took a plain<</>>fast path, which is a 32-bit operation here:shiftLeftInt(127, 28)returned4026531840instead of34091302912,
and any shift of 32 or more returned0.shiftRightInttruncated its operand before shifting, so
shiftRightInt(9007199254740991, 7)returned33554431instead of
70368744177663.- Both now fall back to [BigInt] outside the range the 32-bit operators
handle exactly. Negative operands already did.
- This corrupted LEB128 encoding and decoding on the web for magnitudes past
2^28.
- Fixed
-
Leb128/BytesBufferLeb128Extension(web):- Fixed the value accumulator, which was truncating at 32 bits. The
decoders folded each 7-bit group in with|=, and|is also a 32-bit
operation on the web, so any value past 2^32 lost its high bits. The groups
occupy disjoint bit ranges, so+is equivalent and stays exact. - Fixed signed decoding for magnitudes past ~2^49. A LEB128 negative
sign-extends into every bit below its terminating byte, so the unsigned
form of a negative value is roughly2^shift— far larger than the value
itself, and past the range a JavaScript double represents exactly, even
when the value is comfortably inside it. The accumulator is now split at 49
bits and the halves recombined with [BigInt] only when the value reaches
that far.DateTime.microsecondsSinceEpochsits in the affected range
(about 2^50.6), so a pre-1970 timestamp decoded to the wrong number on the
web while looking entirely ordinary.
- Fixed the value accumulator, which was truncating at 32 bits. The
-
BytesBufferLeb128Extension:- Fixed
readLeb128SignedInt: it decoded almost every signed value
incorrectly, on every platform.- The sign of a LEB128 value lives in bit 6 of its terminating byte, but
lastBytewas assigned after thebreak, so it only ever held the
previous continuation byte — or0for a single-byte value. - Every negative value came back positive:
-1read as127,-2as
126,-64as64. - Multi-byte positives were affected in the other direction:
64encodes as
[0xC0, 0x00], and reading the sign from0xC0turned it into-16320;
1000became-15384. - Values whose terminating and preceding bytes happened to agree on bit 6
decoded correctly by luck, which is why the existing-1000000test
passed throughout. - The static
Leb128.decodeSignedwas never affected — it reads the sign
from the correct byte — so encoding was always right and only the
BytesBufferread path was wrong.
- The sign of a LEB128 value lives in bit 6 of its terminating byte, but
- Fixed
-
Tests:
- Added regression tests for
readLeb128SignedInt: single-byte negatives,
multi-byte positives, a wide range of magnitudes, interleaved signed and
unsigned reads in one buffer, and a cross-check pinning the buffer reader to
Leb128.decodeSignedso a fix on one side cannot be undone on the other. - Added range tests for signed and unsigned reads from 2^28 up to 2^53-1, and
a case at microsecond-timestamp magnitudes, which is where the signed
accumulator went wrong on the web. - Added direct tests for
shiftLeftIntandshiftRightIntacross and beyond
the 32-bit boundary, checked againstBigInt, for positive and negative
operands. - Ranges are built by multiplication rather than
1 << 40, since a shift is a
32-bit operation on the web and such a literal is silently0there — a
test written that way does not check what it appears to.
- Added regression tests for
-
CI:
.github/workflows/dart.yml: the Chrome job now collects and uploads
coverage too. The two platforms run different implementations —
platform_generic.dartis the web one and is never loaded on the VM — so a
VM-only report left every web-only line permanently unmeasured, whatever
the tests actually did. That is precisely where three of the four bugs
above were hiding.- Added
data_serializer_edge_cases_test.dartcovering paths the suite had
not reached:BytesEmitter's rejection of data types it cannot represent,
BytesBufferError.toString, theBytesIOtransfer defaults, the
ByteDataExtensionlength-range checks,DataSerializerPlatform's 64-bit
reads,BitsBuffer.isAtPadding/toString,Writable's default buffer
size, andBytesFileIO's public constructor, transfer defaults and capacity
growth. - Coverage: 98.1% → 99.6%.
Release notes
Open source →Four correctness fixes. The first affects every platform; the other three are web-only (
dart2js/dartdevc), where anintis a JavaScript double and the bitwise operators are 32-bit.-
DataSerializerPlatformGeneric(web):- Fixed
shiftLeftIntandshiftRightIntfor non-negative operands. Both took a plain<</>>fast path, which is a 32-bit operation here:shiftLeftInt(127, 28)returned4026531840instead of34091302912, and any shift of 32 or more returned0.shiftRightInttruncated its operand before shifting, soshiftRightInt(9007199254740991, 7)returned33554431instead of70368744177663.- Both now fall back to [BigInt] outside the range the 32-bit operators handle exactly. Negative operands already did.
- This corrupted LEB128 encoding and decoding on the web for magnitudes past 2^28.
- Fixed
-
Leb128/BytesBufferLeb128Extension(web):- Fixed the value accumulator, which was truncating at 32 bits. The
decoders folded each 7-bit group in with
|=, and|is also a 32-bit operation on the web, so any value past 2^32 lost its high bits. The groups occupy disjoint bit ranges, so+is equivalent and stays exact. - Fixed signed decoding for magnitudes past ~2^49. A LEB128 negative
sign-extends into every bit below its terminating byte, so the unsigned
form of a negative value is roughly
2^shift— far larger than the value itself, and past the range a JavaScript double represents exactly, even when the value is comfortably inside it. The accumulator is now split at 49 bits and the halves recombined with [BigInt] only when the value reaches that far.DateTime.microsecondsSinceEpochsits in the affected range (about 2^50.6), so a pre-1970 timestamp decoded to the wrong number on the web while looking entirely ordinary.
- Fixed the value accumulator, which was truncating at 32 bits. The
decoders folded each 7-bit group in with
-
BytesBufferLeb128Extension:- Fixed
readLeb128SignedInt: it decoded almost every signed value incorrectly, on every platform.- The sign of a LEB128 value lives in bit 6 of its terminating byte, but
lastBytewas assigned after thebreak, so it only ever held the previous continuation byte — or0for a single-byte value. - Every negative value came back positive:
-1read as127,-2as126,-64as64. - Multi-byte positives were affected in the other direction:
64encodes as[0xC0, 0x00], and reading the sign from0xC0turned it into-16320;1000became-15384. - Values whose terminating and preceding bytes happened to agree on bit 6
decoded correctly by luck, which is why the existing
-1000000test passed throughout. - The static
Leb128.decodeSignedwas never affected — it reads the sign from the correct byte — so encoding was always right and only theBytesBufferread path was wrong.
- The sign of a LEB128 value lives in bit 6 of its terminating byte, but
- Fixed
-
Tests:
- Added regression tests for
readLeb128SignedInt: single-byte negatives, multi-byte positives, a wide range of magnitudes, interleaved signed and unsigned reads in one buffer, and a cross-check pinning the buffer reader toLeb128.decodeSignedso a fix on one side cannot be undone on the other. - Added range tests for signed and unsigned reads from 2^28 up to 2^53-1, and a case at microsecond-timestamp magnitudes, which is where the signed accumulator went wrong on the web.
- Added direct tests for
shiftLeftIntandshiftRightIntacross and beyond the 32-bit boundary, checked againstBigInt, for positive and negative operands. - Ranges are built by multiplication rather than
1 << 40, since a shift is a 32-bit operation on the web and such a literal is silently0there — a test written that way does not check what it appears to.
- Added regression tests for
-
CI:
.github/workflows/dart.yml: the Chrome job now collects and uploads coverage too. The two platforms run different implementations —platform_generic.dartis the web one and is never loaded on the VM — so a VM-only report left every web-only line permanently unmeasured, whatever the tests actually did. That is precisely where three of the four bugs above were hiding.- Added
data_serializer_edge_cases_test.dartcovering paths the suite had not reached:BytesEmitter's rejection of data types it cannot represent,BytesBufferError.toString, theBytesIOtransfer defaults, theByteDataExtensionlength-range checks,DataSerializerPlatform's 64-bit reads,BitsBuffer.isAtPadding/toString,Writable's default buffer size, andBytesFileIO's public constructor, transfer defaults and capacity growth. - Coverage: 98.1% → 99.6%.
-
-
1.2.202 May 2026Release notes
Open source →-
CI:
.github/workflows/dart.yml: updated GitHub Actionsactions/checkoutfrom v3 to v6 andcodecov/codecov-actionfrom v3 to v6.
-
BytesBuffer:- Added
writeNullableandreadNullablemethods to write/read nullable objects with a presence boolean flag. - Added
writeJSONandreadJSONmethods to serialize/deserialize JSON-encodable objects as strings. - Reformatted constructor parameter formatting for consistency.
- Minor formatting and whitespace fixes.
- Added
-
Tests (
data_serializer_bytes_buffer_test_base.dart):- Improved formatting and style consistency.
- Added comprehensive tests for
writeNullable/readNullablecovering null, non-null, custom objects, and sequential values. - Added comprehensive tests for
writeJSON/readJSONcovering maps, lists, primitives, sequential values, and equivalence to direct JSON encode/decode. - Added more explicit expectations and improved test readability.
-
pubspec.yaml:- Updated Dart SDK constraint to
>=3.10.0 <4.0.0. - Updated dependencies:
collectionto^1.19.1lintsto^5.1.1testto^1.31.1coverageto^1.15.0pathto^1.9.1
- Updated Dart SDK constraint to
Release notes
Open source →-
CI:
.github/workflows/dart.yml: updated GitHub Actionsactions/checkoutfrom v3 to v6 andcodecov/codecov-actionfrom v3 to v6.
-
BytesBuffer:- Added
writeNullableandreadNullablemethods to write/read nullable objects with a presence boolean flag. - Added
writeJSONandreadJSONmethods to serialize/deserialize JSON-encodable objects as strings. - Reformatted constructor parameter formatting for consistency.
- Minor formatting and whitespace fixes.
- Added
-
Tests (
data_serializer_bytes_buffer_test_base.dart):- Improved formatting and style consistency.
- Added comprehensive tests for
writeNullable/readNullablecovering null, non-null, custom objects, and sequential values. - Added comprehensive tests for
writeJSON/readJSONcovering maps, lists, primitives, sequential values, and equivalence to direct JSON encode/decode. - Added more explicit expectations and improved test readability.
-
pubspec.yaml:- Updated Dart SDK constraint to
>=3.10.0 <4.0.0. - Updated dependencies:
collectionto^1.19.1lintsto^5.1.1testto^1.31.1coverageto^1.15.0pathto^1.9.1
- Updated Dart SDK constraint to
-
-
1.2.114 Aug 2024Release notes
Open source →-
Rollback to
collection 1.18.0for Flutter SDK compatibility. -
collection: ^1.18.0
Release notes
Open source →-
Rollback to
collection 1.18.0for Flutter SDK compatibility. -
collection: ^1.18.0
-
-
1.2.006 Aug 2024Release notes
Open source →-
Remove use of
UnmodifiableUint8ListViewfor Dart 3.5.0 compatibility. -
sdk: '>=3.4.0 <4.0.0'
-
collection: ^1.19.0
-
test: ^1.25.8
-
coverage: ^1.9.0
Release notes
Open source →-
Remove use of
UnmodifiableUint8ListViewfor Dart 3.5.0 compatibility. -
sdk: '>=3.4.0 <4.0.0'
-
collection: ^1.19.0
-
test: ^1.25.8
-
coverage: ^1.9.0
-
-
1.1.015 Feb 2024Release notes
Open source →Dart
3.3.0compatibility changes:-
ListGenericExtension:- Renamed getter
asUnmodifiableViewto methodasUnmodifiableListView.
- Renamed getter
-
Uint8ListDataExtension:- Removed getter
asUnmodifiableViewto allow use ofUint8List.asUnmodifiableView.
- Removed getter
-
Uint32ListDataExtension:- Removed getter
asUnmodifiableViewto allow use ofUint32List.asUnmodifiableView.
- Removed getter
-
Uint64ListDataExtension:- Removed getter
asUnmodifiableViewto allow use ofUint64List.asUnmodifiableView.
- Removed getter
-
sdk: '>=3.3.0 <4.0.0'
-
lints: ^3.0.0
-
test: ^1.25.2
-
coverage: ^1.7.2
-
path: ^1.9.0
Release notes
Open source →Dart
3.3.0compatibility changes:-
ListGenericExtension:- Renamed getter
asUnmodifiableViewto methodasUnmodifiableListView.
- Renamed getter
-
Uint8ListDataExtension:- Removed getter
asUnmodifiableViewto allow use ofUint8List.asUnmodifiableView.
- Removed getter
-
Uint32ListDataExtension:- Removed getter
asUnmodifiableViewto allow use ofUint32List.asUnmodifiableView.
- Removed getter
-
Uint64ListDataExtension:- Removed getter
asUnmodifiableViewto allow use ofUint64List.asUnmodifiableView.
- Removed getter
-
sdk: '>=3.3.0 <4.0.0'
-
lints: ^3.0.0
-
test: ^1.25.2
-
coverage: ^1.7.2
-
path: ^1.9.0
-
-
1.0.1226 Oct 2023Release notes
Open source →Merge v1.0.12 (BitsBuffer)
v1.0.12
- New `BitsBuffer`.
- `BytesBuffer`:
- `writeWritables/readWritables`: new parameter option `leb128`.
- Added `writeFloat64`, `writeAllFloat64`, `readFloat64` and `readAllFloat64`.
- Added `writeFloat32`, `writeAllFloat32`, `readFloat32` and `readAllFloat32`.
- Added `readTo` and `writeFrom`.- test: ^1.24.8
Release notes
Open source →-
New
BitsBuffer. -
BytesBuffer:writeWritables/readWritables: new parameter optionleb128.- Added
writeFloat64,writeAllFloat64,readFloat64andreadAllFloat64. - Added
writeFloat32,writeAllFloat32,readFloat32andreadAllFloat32. - Added
readToandwriteFrom.
-
test: ^1.24.8
-
-
1.0.1130 Sep 2023Release notes
Open source →Merge v1.0.11 - LEB128
- Added support to `Leb128`.
- New `BytesEmitter`.
- `DataSerializerPlatform`:
- Added `supportsFullBitsShift`, `shiftRightInt` and `shiftLeftInt`.- sdk: '>=3.0.0 <4.0.0'
- dependency_validator: ^3.2.3Release notes
Open source →-
Added support to
Leb128. -
New
BytesEmitter. -
DataSerializerPlatform:- Added
supportsFullBitsShift,shiftRightIntandshiftLeftInt.
- Added
-
sdk: '>=3.0.0 <4.0.0'
-
dependency_validator: ^3.2.3
-
-
1.0.1015 Aug 2023 -
1.0.915 Aug 2023Release notes
Open source →Merge v1.0.9
- `BytesIO`:
- Added `flush`, `close`, `isClosed` and `supportsClosing`.
- `BytesBuffer`:
- Added `flush` and `close`.Release notes
Open source →BytesIO:- Added
flush,close,isClosedandsupportsClosing.
- Added
BytesBuffer:- Added
flushandclose.
- Added
-
1.0.815 Aug 2023Release notes
Open source →-
New
BytesIO:- Implementations:
BytesFileIOandBytesUint8ListIO.
- Implementations:
-
Added constructor
BytesBuffer.fromIO. -
DataSerializerPlatformGeneric:- Fixed
_writeInt64and_readInt64for JS/Browser platform.
- Fixed
-
Dart CI:
- Tests platforms: vm, exe, chrome.
-
sdk: '>=2.18.4 <4.0.0'
-
collection: ^1.18.0
-
lints: ^2.0.1
-
test: ^1.24.3
-
dependency_validator: ^3.2.2
-
coverage: ^1.6.3
-
-
1.0.719 Feb 2022Release notes
Open source →v1.0.7
- `ListIntDataExtension`:
- Added `toInt8List`, `toUint16List`, `toInt16List`,
`toUint32List`, `toInt32List`,`toUint64List`, `toInt64List`.
- Added `asInt8List``asUint16List`, `asInt16List`,
`asUint32List`, `asInt32List`, `asUint64List`, `asInt64List`.
- New `ListGenericExtension`:
- `reversedList`, `copyTo`, `copy`, `asUnmodifiableView`, `reverseChunks`
- - `Uint8ListDataExtension`: added `toUint32List`.
- New `ByteDataExtension`, `Uint32ListDataExtension` and `Uint64ListDataExtension`.
- Improved tests.Release notes
Open source →ListIntDataExtension:- Added
toInt8List,toUint16List,toInt16List,toUint32List,toInt32List,toUint64List,toInt64List. - Added
asInt8List``asUint16List,asInt16List,asUint32List,asInt32List,asUint64List,asInt64List.
- Added
- New
ListGenericExtension:reversedList,copyTo,copy,asUnmodifiableView,reverseChunks
-
Uint8ListDataExtension: addedtoUint32List.
- New
ByteDataExtension,Uint32ListDataExtensionandUint64ListDataExtension. - Improved tests.
-
1.0.611 Feb 2022Release notes
Open source →DataSerializerPlatform, andUint8ListDataExtension:getInt16/32/64andgetUint16/32/64:- Added parameter
endianto allowEndian.little.
- Added parameter
-
1.0.507 Jan 2022 -
1.0.405 Jan 2022 -
1.0.304 Jan 2022 -
1.0.204 Jan 2022 -
1.0.104 Jan 2022 -
1.0.004 Jan 2022Release notes
Open source →- Initial version.
- Moved some code from package
statistics. - Added support for browser/js.
- base_codecs: ^1.0.1
- collection: ^1.15.0