New Dart prose, update Dart and Ts code + guide/server-communication/ts: update to docs and example code + guide/server-communication/dart: new prose, update example code + ignore all npm-debug.logs + make Jade ul li TOC elements more compact.
15 lines
305 B
Dart
15 lines
305 B
Dart
// #docregion
|
|
class Hero {
|
|
final int id;
|
|
final String name;
|
|
|
|
Hero(this.id, this.name);
|
|
|
|
factory Hero.fromJson(Map<String, dynamic> hero) =>
|
|
new Hero(_toInt(hero['id']), hero['name']);
|
|
|
|
Map toJson() => {'id': id, 'name': name};
|
|
|
|
static int _toInt(id) => id is int ? id : int.parse(id);
|
|
}
|