Closed shreyas1599 closed 4 years ago
@pd4d10 I could use some help. Consider the json output for getting gists.
Files
is another json and not a list. I'm having trouble serializing this. The Spinlocklabs github.dart
declares it as a list which is wrong and results in an error. I've opened an issue there. This is what I've done for now.
class GithubGistsItem {
String id;
String description;
bool public;
Map<String, GistFiles> files;
GithubEventUser owner;
List<dynamic> get fileNames {
var filenames = [];
files.forEach((String key, GistFiles value) {
filenames.add(value);
});
return filenames;
}
DateTime createdAt;
DateTime updatedAt;
GithubGistsItem();
factory GithubGistsItem.fromJson(Map<String, dynamic> json) =>
_$GithubGistsItemFromJson(json);
}
But making fileNames
dynamic is creating problems everywhere and I'm not sure if this is the right way to serialize it. For instance, I am unable to use the ObjectTree
widget. I have created another widget file and solved the problem but I think re-using the ObjectTree
widget is a better way to go. The error is something to do with fileNames being dynamic. Any help is appreciated. Thanks.
What's the error message (or error stack)?
type 'MappedListIterable<dynamic, dynamic>' is not a subtype of type 'Iterable<ObjectTreeItem>'
This is what I tried to do:
return ObjectTree(
items: payload.fileNames.map((v) {
return ObjectTreeItem(
url: '',
type: v.type,
name: v.filename,
downloadUrl: v.rawUrl,
);
}),
);
How about using files.values()
?
Or files.entries()
if you want the key too
Doesn't work. Still getting the same error.
Oh, my mistake. values
and entries
are getters, not methods.
Perhaps you could submit a WIP pull request so I could help to check it.
Oh, my mistake.
values
andentries
are getters, not methods.
I used them as getters only. Does it make a difference if it's a getter and not a method for this case?
Add user's gists in the profile section.