Returns real-time data from your table as a Stream
.
stream()
will emit the initial data as well as any further change on the database as Stream<List<Map<String, dynamic>>>
by combining Postgrest and Realtime..eq('column', value)
listens to rows where the column equals the value.neq('column', value)
listens to rows where the column does not equal the value.gt('column', value)
listens to rows where the column is greater than the value.gte('column', value)
listens to rows where the column is greater than or equal to the value.lt('column', value)
listens to rows where the column is less than the value.lte('column', value)
listens to rows where the column is less than or equal to the value.inFilter('column', [val1, val2, val3])
listens to rows where the column is one of the valuessupabase.from('countries')
.stream(primaryKey: ['id'])
.listen((List<Map<String, dynamic>> data) \{
// Do something awesome with the data
\});
supabase.from('countries')
.stream(primaryKey: ['id'])
.eq('id', 120)
.order('name')
.limit(10);
supabase.from('countries')
.stream(primaryKey: ['id'])
.inFilter('id', [1, 2, 3])
.order('name')
.limit(10);
final supabase = Supabase.instance.client;
class MyWidget extends StatefulWidget \{
const MyWidget(\{Key? key\}) : super(key: key);
@override
State<MyWidget> createState() => _MyWidgetState();
\}
class _MyWidgetState extends State<MyWidget> \{
// Persist the stream in a local variable to prevent refetching upon rebuilds
final _stream = supabase.from('countries').stream(primaryKey: ['id']);
@override
Widget build(BuildContext context) \{
return StreamBuilder(
stream: _stream,
builder: (context, snapshot) \{
// Return your widget with the data from the snapshot
\},
);
\}
\}