Skip to content

Instantly share code, notes, and snippets.

@danschultz
Created September 8, 2015 19:05
Show Gist options
  • Save danschultz/b21a5044e33bb7ad5aae to your computer and use it in GitHub Desktop.
Save danschultz/b21a5044e33bb7ad5aae to your computer and use it in GitHub Desktop.
Dart auto-gen records
library autogen_models;
import 'package:option/options.dart';
class Person {
final String name;
final int age;
final Option<Person>;
Person(this.name, this.age, this.person);
}
// Defines the name of the Record and the fields the record contains that will get
// autogenerated. The autogenerated file would contain a constructor and update
// method.
@Record("Person", const {"name": String, "age": int, "spouse": Option<Person>})
library models;
import 'package:option/options.dart';
import 'records.dart';
library record;
class Record {
final Map<String, Type> definition;
const Record(this.definition);
bool operator ==(other) => this == other;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment