How can I make this work? I don't know how to code it. Can you help me?I want to take all users from firebase and filter them in a search page
static Stream<List<UserModel>> searchUserFuture({required String query}) {
query = query.toLowerCase();
List<UserModel> l;
_fireStoreUserCollection
.snapshots()
.map((snapshot) => snapshot.docs.map((doc) {
int matchs = 0;
UserModel user =
UserModel.fromJson(jsonDecode(jsonEncode(doc.data())));
if (user.name.contains(query) ||
user.lastName.contains(query) ||
user.level.contains(query) ||
user.location.contains(query)) {
matchs++;
}
for (int j = 0; j < user.best.length; j++) {
if (user.best[j].nameB.contains(query)) {
matchs++;
}
}
for (int k = 0; k < user.initial.length; k++) {
if (user.initial[k].nameI.contains(query)) {
matchs++;
}
if (user.initial[k].type.contains(query)) {
matchs++;
}
}
if (matchs > 0) {
l.add(user);
}
return l;
}));
}