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

Commit 8259dda

Browse files
use changes from v1.5.0
1 parent df2ddc3 commit 8259dda

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/pages/guides/dart/flutter.mdx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,13 @@ import 'dart:convert';
116116
117117
api.get("/favorites", (ctx) async {
118118
// Get a list of all the keys in the store
119-
var keyStream = await favoritesKV.keys();
119+
var keys = await favouritesKV.keys();
120120
121-
// Convert the keys to a list of favorites
122-
var favorites = await keyStream.asyncMap((k) async {
123-
final favorite = await favoritesKV.get(k);
121+
var favourites = await Future.wait(keys.map((k) async {
122+
final favourite = await favouritesKV.get(k);
124123
125-
return favorite;
126-
}).toList();
124+
return favourite;
125+
}).toList());
127126
128127
// Return the body as a list of favorites
129128
ctx.res.body = jsonEncode(favorites);
@@ -147,10 +146,10 @@ api.post("/favorite", (ctx) async {
147146
final favorite = favorite.fromJson(req);
148147
149148
// search for the key, filtering by the name of the favorite
150-
final stream = await favoritesKV.keys(prefix: favorite.name);
149+
final keys = await favoritesKV.keys(prefix: favorite.name);
151150
152151
// checks if the favorite exists in the list of keys
153-
final exists = await stream.any((f) => f == favorite.name);
152+
final exists = keys.any((f) => f == favorite.name);
154153
155154
// if it exists delete and return
156155
if (exists) {

0 commit comments

Comments
 (0)