- Summary of my problem
I’m new in Flutter(Dart) and I came across this problem. All lists of the type String naturally have the string methods like item.length, item.contains and so on. But when you create a random List type, it gets none of that.
Error message: ‘length’
method not found
Receiver: Instance of ‘Recipe’
Arguments: []
- What have I tried so far -
I have tried implementing all the string methods to that Random class one by one, but it just seems wrong. I should be able to have those methods easier
- Here’s the minimum code you would need to reproduce the problem -
dummySearchList.forEach((item) {
void findPersonUsingLoop(item ,
String query) {
for (var i = 0; i < item.length; i++) {
if (item[i].title == query) {
print('Using loop: ${item[i]}');
dummyListData.add(item);
// Found the person, stop the loop
return;
}
}
}
findPersonUsingLoop(item,query); ```