Subscribe to realtime changes in your database.
REPLICA IDENTITY
to FULL
, like this: ALTER TABLE your_table REPLICA IDENTITY FULL;
supabase
.channel('public:countries')
.onPostgresChanges(
event: PostgresChangeEvent.all,
schema: 'public',
table: 'countries',
callback: (payload) \{
print('Change received: $\{payload.toString()\}');
\})
.subscribe();
supabase
.channel('public:countries')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'countries',
callback: (payload) \{
print('Change received: $\{payload.toString()\}');
\})
.subscribe();
supabase
.channel('public:countries')
.onPostgresChanges(
event: PostgresChangeEvent.update,
schema: 'public',
table: 'countries',
callback: (payload) \{
print('Change received: $\{payload.toString()\}');
\})
.subscribe();
supabase
.channel('public:countries')
.onPostgresChanges(
event: PostgresChangeEvent.delete,
schema: 'public',
table: 'countries',
callback: (payload) \{
print('Change received: $\{payload.toString()\}');
\})
.subscribe();
supabase
.channel('public:countries')
.onPostgresChanges(
event: PostgresChangeEvent.insert,
schema: 'public',
table: 'countries',
callback: (payload) \{
print('Insert event received: $\{payload.toString()\}');
\})
.onPostgresChanges(
event: PostgresChangeEvent.delete,
schema: 'public',
table: 'countries',
callback: (payload) \{
print('Delete event received: $\{payload.toString()\}');
\})
.subscribe();
supabase
.channel('public:countries:id=eq.200')
.onPostgresChanges(
event: PostgresChangeEvent.delete,
schema: 'public',
table: 'countries',
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.eq,
column: 'id',
value: 200,
),
callback: (payload) \{
print('Change received: $\{payload.toString()\}');
\})
.subscribe();
supabase
.channel('room1')
.onBroadcast(
event: 'cursor-pos',
callback: (payload) \{
print('Cursor position received!: $payload');
\})
.subscribe();
final channel = supabase.channel('room1');
channel.onPresenceSync((payload) \{
print('Synced presence state: $\{channel.presenceState()\}');
\}).onPresenceJoin((payload) \{
print('Newly joined presences $payload');
\}).onPresenceLeave((payload) \{
print('Newly left presences: $payload');
\}).subscribe((status, error) async \{
if (status == RealtimeSubscribeStatus.subscribed) \{
await channel.track(\{'online_at': DateTime.now().toIso8601String()\});
\}
\});