You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
| ///
 | |
| /// This example was taken from
 | |
| /// https://flutter.dev/docs/development/data-and-backend/json
 | |
| ///
 | |
| 
 | |
| /// This allows the `User` class to access private members in
 | |
| /// the generated file. The value for this is *.g.dart, where
 | |
| /// the star denotes the source file name.
 | |
| 
 | |
| /// An annotation for the code generator to know that this class needs the
 | |
| /// JSON serialization logic to be generated.
 | |
| 
 | |
| class BackendResponse {
 | |
|   BackendResponse({required this.id, required this.isOk, required this.result});
 | |
| 
 | |
|   int id;
 | |
|   bool isOk;
 | |
|   dynamic result;
 | |
| 
 | |
|   /// A necessary factory constructor for creating a new User instance
 | |
|   /// from a map. Pass the map to the generated `_$UserFromJson()` constructor.
 | |
|   /// The constructor is named after the source class, in this case, User.
 | |
|   factory BackendResponse.fromJson(Map<String, dynamic> json) =>
 | |
|       BackendResponse(
 | |
|         id: 1,
 | |
|         isOk: false,
 | |
|         result: null,
 | |
|       );
 | |
| //
 | |
| // /// `toJson` is the convention for a class to declare support for serialization
 | |
| // /// to JSON. The implementation simply calls the private, generated
 | |
| // /// helper method `_$UserToJson`.
 | |
| // Map<String, dynamic> toJson() => _$BackendResponseToJson(this);
 | |
| }
 |