Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 3957e10

Browse files
swap back to stream
1 parent e92fea3 commit 3957e10

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/pages/guides/dart/flutter.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ api.get("/favorites", (ctx) async {
118118
// Get a list of all the keys in the store
119119
var keys = await favouritesKV.keys();
120120
121-
var favourites = await Future.wait(keys.map((k) async {
121+
var favourites = await keys.asyncMap((k) async {
122122
final favourite = await favouritesKV.get(k);
123123
124124
return favourite;
125-
}).toList());
125+
}).toList();
126126
127127
// Return the body as a list of favorites
128128
ctx.res.body = jsonEncode(favorites);
@@ -149,7 +149,12 @@ api.post("/favorite", (ctx) async {
149149
final keys = await favoritesKV.keys(prefix: favorite.name);
150150
151151
// checks if the favorite exists in the list of keys
152-
final exists = keys.any((f) => f == favorite.name);
152+
var exists = false;
153+
await for (var key in keys) {
154+
if (key == favourite.name) {
155+
exists = true;
156+
}
157+
}
153158
154159
// if it exists delete and return
155160
if (exists) {

0 commit comments

Comments
 (0)