supabase 2.6.1 copy "supabase: ^2.6.1" to clipboard
supabase: ^2.6.1 copied to clipboard

A dart client for Supabase. This client makes it simple for developers to build secure and scalable products.

example/main.dart

import 'dart:async';
import 'dart:io';

import 'package:supabase/supabase.dart';

Future<void> main() async {
  const supabaseUrl = 'YOUR_SUPABASE_URL';
  const supabaseKey = 'YOUR_ANON_KEY';
  final supabase = SupabaseClient(supabaseUrl, supabaseKey);

  // query data
  final data =
      await supabase.from('countries').select().order('name', ascending: true);
  print(data);

  // insert data
  await supabase.from('countries').insert([
    {'name': 'Singapore'},
  ]);

  // update data
  await supabase.from('countries').update({'name': 'Singapore'}).eq('id', 1);

  // delete data
  await supabase.from('countries').delete().eq('id', 1);

  // realtime
  final realtimeChannel = supabase.channel('my_channel');
  realtimeChannel
      .onPostgresChanges(
          event: PostgresChangeEvent.all,
          schema: 'public',
          table: 'countries',
          callback: (payload) {})
      .subscribe();

  // remember to remove channel when no longer needed
  supabase.removeChannel(realtimeChannel);

  // stream
  final streamSubscription = supabase
      .from('countries')
      .stream(primaryKey: ['id'])
      .order('name')
      .limit(10)
      .listen((snapshot) {
        print('snapshot: $snapshot');
      });

  // remember to remove subscription
  streamSubscription.cancel();

  // Upload file to bucket "public"
  final file = File('example.txt');
  file.writeAsStringSync('File content');
  final storageResponse =
      await supabase.storage.from('public').upload('example.txt', file);
  print('upload response : $storageResponse');

  // Get download url
  final urlResponse =
      await supabase.storage.from('public').createSignedUrl('example.txt', 60);
  print('download url : $urlResponse');

  // Download text file
  final fileResponse =
      await supabase.storage.from('public').download('example.txt');
  print('downloaded file : ${String.fromCharCodes(fileResponse)}');

  // Delete file
  final deleteFileResponse =
      await supabase.storage.from('public').remove(['example.txt']);
  print('deleted file id : ${deleteFileResponse.first.id}');

  // Local file cleanup
  if (file.existsSync()) file.deleteSync();
}
547
likes
160
points
116k
downloads

Publisher

verified publishersupabase.io

Weekly Downloads

A dart client for Supabase. This client makes it simple for developers to build secure and scalable products.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

functions_client, gotrue, http, logging, postgrest, realtime_client, rxdart, storage_client, yet_another_json_isolate

More

Packages that depend on supabase