| 
									
										
										
										
											2016-02-10 17:27:14 -02:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-05-20 17:14:37 -07:00
										 |  |  | int _toInt(id) => id is int ? id : int.parse(id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-10 17:27:14 -02:00
										 |  |  | class Hero { | 
					
						
							|  |  |  |   final int id; | 
					
						
							|  |  |  |   final String name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Hero(this.id, this.name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-13 13:32:54 -07:00
										 |  |  |   factory Hero.fromJson(Map<String, dynamic> hero) => | 
					
						
							|  |  |  |       new Hero(_toInt(hero['id']), hero['name']); | 
					
						
							| 
									
										
										
										
											2016-02-10 17:27:14 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Map toJson() => {'id': id, 'name': name}; | 
					
						
							|  |  |  | } |