child: StreamBuilder<List<Map<String, dynamic>>>(
stream: Supabase.instance.client.from("todo").stream(
primaryKey: [
{"idx": 1},
],
),
builder: (context, snapshot) {
return ListView(
children: snapshot.data?.map((e) => Text(e["content"])).toList() ?? [],
);
}
);
idx(primary key) | content |
---|---|
1 | one |
2 | two |
I'm trying to get content with idx of 1, but an error keeps occurring, in line 4 >>> {"idx": 1}.
So I wrote this code using chat-gpt, but still the error occurs.
How can I get content with idx of 1?
For the primaryKey
parameter, you just need to pass the list of primary key column names, in this case, just ['ids']
, so your code would look like:
child: StreamBuilder<List<Map<String, dynamic>>>(
stream: Supabase.instance.client.from("todo").stream(primaryKey: ['idx']),
builder: (context, snapshot) {
return ListView(
children: snapshot.data?.map((e) => Text(e["content"])).toList() ?? [],
);
}
);