object_serialization 1.0.2 copy "object_serialization: ^1.0.2" to clipboard
object_serialization: ^1.0.2 copied to clipboard

An object serialization library for Dart and Flutter that supports circular references and preserves identity.

example/main.dart

import 'package:object_serialization/object_serialization.dart';

void main() {
  final s = 'abc';
  // A list with two references to the same string.
  final List<Object> list1 = [s, s];
  // Add the list to itself for a circular reference.
  list1.add(list1);
  assert(identical(list1[0], list1[1]));
  assert(identical(list1, list1[2]));
  final buffer = ObjectSerialization.encode(list1);
  final list2 = ObjectSerialization.decode(buffer, {}) as List;
  // object identity is preserved.
  assert(identical(list2[0], list2[1]));
  // circular reference is preserved.
  assert(identical(list2, list2[2]));
  print('Success!');
}
1
likes
160
points
132
downloads

Publisher

verified publisherfosteragile.com

Weekly Downloads

An object serialization library for Dart and Flutter that supports circular references and preserves identity.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on object_serialization