supabase 1.9.5 copy "supabase: ^1.9.5" to clipboard
supabase: ^1.9.5 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
      .on(
          RealtimeListenTypes.postgresChanges,
          ChannelFilter(event: '*', schema: 'public', table: 'countries'),
          (payload, [ref]) {})
      .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();
}
540
likes
0
pub points
98%
popularity

Publisher

verified publishersupabase.io

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

License

unknown (license)

Dependencies

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

More

Packages that depend on supabase