Created
September 8, 2015 19:05
-
-
Save danschultz/b21a5044e33bb7ad5aae to your computer and use it in GitHub Desktop.
Dart auto-gen records
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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