get_packer 1.0.0 copy "get_packer: ^1.0.0" to clipboard
get_packer: ^1.0.0 copied to clipboard

A high-performance serialization library for Dart, designed to efficiently pack and unpack data structures. It provides a fast and compact alternative to JSON encoding/decoding and MessagePack

example/example.md

import 'package:get_packer/get_packer.dart';

void main() {
  // Encoding
  final data = {
    'name': 'John Doe',
    'age': 30,
    'isStudent': false,
    'grades': [85, 90, 92],
  };

  final encoded = GetPacker.pack(data);

  // Decoding
  final decoded = GetPacker.unpack(encoded);

  print(decoded); // Output: {name: John Doe, age: 30, isStudent: false, grades: [85, 90, 92]}
}

Using with Custom Objects #

You can use the PackedModel mixin to easily serialize and deserialize custom objects:

class User with PackedModel {
  String name;
  int age;

  User(this.name, this.age);

  @override
  Map<String, dynamic> toJson() => {'name': name, 'age': age};

  @override
  static User fromJson<User extends PackedModel>(Map<String, dynamic> json) {
    return User(json['name'], json['age']);
  }
}

void main() {
  final user = User('Alice', 25);

  // Packing
  final packed = user.pack();

  // Unpacking
  final unpackedUser = User.fromJson(unpack(packed));

  print('${unpackedUser.name}, ${unpackedUser.age}'); // Output: Alice, 25
}
6
likes
150
points
53
downloads

Publisher

verified publishergetx.site

Weekly Downloads

A high-performance serialization library for Dart, designed to efficiently pack and unpack data structures. It provides a fast and compact alternative to JSON encoding/decoding and MessagePack

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on get_packer