Skip to content

Commit 3ad7f37

Browse files
committed
make RepositoryContents json serializable
1 parent e0d0472 commit 3ad7f37

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/src/common/model/repos_contents.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,22 @@ class Links {
8787
}
8888

8989
/// Model class for a file or directory.
90+
@JsonSerializable(fieldRename: FieldRename.snake)
9091
class RepositoryContents {
92+
RepositoryContents({
93+
this.file,
94+
this.tree,
95+
});
9196
GitHubFile file;
9297
List<GitHubFile> tree;
9398

9499
bool get isFile => file != null;
95100
bool get isDirectory => tree != null;
101+
102+
factory RepositoryContents.fromJson(Map<String, dynamic> json) =>
103+
_$RepositoryContentsFromJson(json);
104+
105+
Map<String, dynamic> toJson() => _$RepositoryContentsToJson(this);
96106
}
97107

98108
/// Model class for a new file to be created.

lib/src/common/model/repos_contents.g.dart

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)