Skip to content

Instantly share code, notes, and snippets.

@hasimyerlikaya
Last active March 20, 2020 07:20
Show Gist options
  • Save hasimyerlikaya/cb3d89dc3048529a28f5efcf2e349f51 to your computer and use it in GitHub Desktop.
Save hasimyerlikaya/cb3d89dc3048529a28f5efcf2e349f51 to your computer and use it in GitHub Desktop.
You can clone dart object easily.
factory SearchRequest.fromJson(Map<String, dynamic> json) => _$SearchRequestFromJson(json);
Map<String, dynamic> toJson() => _$SearchRequestToJson(this);
SearchRequest clone() {
final String jsonString = json.encode(this);
final jsonResponse = json.decode(jsonString);
return SearchRequest.fromJson(jsonResponse as Map<String, dynamic>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment