Skip to content

Instantly share code, notes, and snippets.

@Sfshaza
Last active February 9, 2016 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sfshaza/e57aa06401e6618d4eb8 to your computer and use it in GitHub Desktop.
Save Sfshaza/e57aa06401e6618d4eb8 to your computer and use it in GitHub Desktop.
ch02
class Person {
String firstName;
Person.fromJson(Map data) {
print('in Person');
}
}
class Employee extends Person {
// Person does not have a default constructor;
// you must call super.fromJson(data).
Employee.fromJson(Map data) : super.fromJson(data) {
print('in Employee');
}
}
main() {
var emp = new Employee.fromJson({});
// Prints:
// in Person
// in Employee
if (emp is Person) {
// Type check
emp.firstName = 'Bob';
}
(emp as Person).firstName = 'Bob';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment