artifact 1.0.34 copy "artifact: ^1.0.34" to clipboard
artifact: ^1.0.34 copied to clipboard

Data Modeling for the local madman

example/lib/example.dart

import 'package:artifact/artifact.dart';
import 'package:example/gen/artifacts.gen.dart';

const Artifact model = Artifact(compression: true, reflection: true);

@model
class Holder {
  final Map<String, AMeta> aMetas;
  final Map<String, BMeta> bMetas;

  const Holder({this.aMetas = const {}, this.bMetas = const {}});
}

@model
class Meta {
  const Meta();
}

@model
class AMeta extends Meta {
  final int a;

  const AMeta({this.a = 4});
}

@model
class BMeta extends Meta {
  final String b;

  const BMeta({this.b = "hello"});
}

void main() {
  Holder h = Holder(
    aMetas: {"a1": AMeta(a: 5)},
    bMetas: {"b1": BMeta(b: "world")},
  );

  print(h.to.json);

  Holder h2 = $Holder.from.json(h.to.json);

  print(h2.to.json);
}

@artifact
class VectorValue {
  final String magic$type;
  final List<double> vector;

  const VectorValue({this.magic$type = "vector", this.vector = const []});
}
1
likes
115
points
552
downloads

Documentation

API reference

Publisher

verified publisherarcane.art

Weekly Downloads

Data Modeling for the local madman

Repository (GitHub)
View/report issues

License

GPL-3.0 (license)

Dependencies

bson, fast_log, json_compress, threshold, toml, toonx, toxic, yaml, yaml_edit

More

Packages that depend on artifact