entity_format 0.0.5 copy "entity_format: ^0.0.5" to clipboard
entity_format: ^0.0.5 copied to clipboard

unlistedoutdated

A serialization code-generation-less serialization library.

entity_format is a serialization library which doesn't require code generation.

[Work-In-Progress]

Still not ready for production.

Example:

import 'package:entity_format/serialization.dart';

class GetDownloadLinksResponse with Serializable {
  final String bucket;
  static const bucketField = Field('bucket');

  final String index;
  static const indexField = Field('index');

  final String created;
  static const createdField = Field('created');

  final List<DownloadableShard> shards;
  static const shardsField = Field('shards');

  final int? version;
  static const versionField = Field('version');

  final int size;
  static const sizeField = Field('size');

  const GetDownloadLinksResponse({
    required this.bucket,
    required this.index,
    required this.created,
    required this.shards,
    required this.version,
    required this.size,
  });

  GetDownloadLinksResponse.fromEntity(EntityReader entity)
      : bucket = entity.get(bucketField),
        index = entity.get(indexField),
        created = entity.get(createdField),
        shards = entity.getList(shardsField)!,
        version = entity.get(versionField),
        size = entity.get(sizeField);

  @override
  Entity toEntity() {
    return Entity({
      bucketField: bucket,
      indexField: index,
      createdField: created,
      shardsField: shardsField,
      versionField: version,
      sizeField: size,
    });
  }
}

Might seem like a lot of boilerplate, but trust me — you will save time in the long run. You can effortlessly customize your serialization by editing the toEntity() and fromEntity() methods.

0
likes
0
points
125
downloads

Publisher

verified publisherdreamscenter.com

Weekly Downloads

A serialization code-generation-less serialization library.

License

unknown (license)

Dependencies

collection, flutter, kt_dart, protobuf

More

Packages that depend on entity_format