Reputation: 13
Dart/Flutter: I have a class which is fetching data from a server and returning a list but ListView.builder is throwing the error: The getter 'length' isn't defined for the type 'Search'.
**Here is the code of Search Class: **
class Search {
String query;
Search(query) {
this.query = query;
HttpClient()
.getUrl(Uri.parse('https://api-request-url/search'))
.then((request) => request.close())
.then((response) async {
response.transform(Utf8Decoder()).listen((event) {
return event;
});
}
);
}
}
Upvotes: 0
Views: 1152
Reputation: 1456
You aren't assigning returning event
to anything.
Your class Search
doesn't contain any iterable
variable. Length of what exactly you want to get?
Upvotes: 0