artifact 1.0.25 copy "artifact: ^1.0.25" to clipboard
artifact: ^1.0.25 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: false, reflection: true);

class NoRelfect {
  const NoRelfect();
}

@model
class DoReflect {
  const DoReflect();
}

@model
class NoOp {}

@model
class Person {
  @deprecated
  final String firstName;

  @DoReflect()
  @NoRelfect()
  final String lastName;
  @DoReflect()
  final DateTime? dateOfBirth;

  Person({required this.firstName, required this.lastName, this.dateOfBirth});

  @override
  bool operator ==(Object other) {
    return super == other;
  }

  @NoRelfect()
  @override
  int get hashCode => super.hashCode;

  @DoReflect()
  @override
  String toString() {
    return "f";
  }
}

void main() {
  Person p = Person(firstName: "John", lastName: "Doe");

  for (ArtifactAnnotatedField<DoReflect> i
      in p.$mirror.getAnnotatedFields<DoReflect>()) {
    DoReflect a = i.annotation;
    ArtifactFieldMirror f = i.field;
    dynamic value = f.value;
    print("${f.name} = $value");
  }
}
0
likes
120
points
623
downloads

Publisher

verified publisherarcane.art

Weekly Downloads

Data Modeling for the local madman

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

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

More

Packages that depend on artifact