supabase 0.0.1-dev.21 copy "supabase: ^0.0.1-dev.21" to clipboard
supabase: ^0.0.1-dev.21 copied to clipboard

outdated

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

supabase-dart #

A dart client for Supabase.

pub package pub test


What is Supabase #

Supabase is an open source Firebase alternative. We are a service to:

  • listen to database changes
  • query your tables, including filtering, pagination, and deeply nested relationships (like GraphQL)
  • create, update, and delete rows
  • manage your users and their permissions
  • interact with your database using a simple UI

Usage example #

Database #

import 'package:supabase/supabase.dart';

main() {
  final client = SupabaseClient('supabaseUrl', 'supabaseKey');
  
  // Select from table `countries` ordering by `name`
  final response = await client
      .from('countries')
      .select()
      .order('name', ascending: true)
      .execute();
}

Authentication #

import 'package:supabase/supabase.dart';

main() {
  final client = SupabaseClient('supabaseUrl', 'supabaseKey');

  // Sign up user with email and password
  final response = await client
      .auth
      .signUp('email', 'password');
}

Storage #

import 'package:supabase/supabase.dart';

main() {
  final client = SupabaseClient('supabaseUrl', 'supabaseKey');
  
  // Create file `example.txt` and upload it in `public` bucket
  final file = File('example.txt');
  file.writeAsStringSync('File content');
  final storageResponse = await client
      .storage
      .from('public')
      .upload('example.txt', file);
}

Authentication #

Initialize a SupabaseClient by passing your Supabase URL and Supabase KEY. The keys can be found in your supabase project in /setting/API.

final client = SupabaseClient('supabaseUrl', 'supabaseKey');

The client has a auth attribute (of type GoTrueClient) that you can use to authenticate your users using supabase.

Sign up #

Use the signUp method, which returns a GotrueSessionResponse.

If the error attribute is null, the request was successful and the method returns data of type Session.

// Sign up user with email and password
final response = await client.auth.signUp('email', 'password');

if (response.error != null) {
  // Error
  print('Error: ${response.error?.message}');
} else {
  // Success
  final session = response.data;
}

Sign in #

Use the signIn method. It works similar to the signUp method.

// Sign in user with email and password
final response = await client.auth.signIn(email: 'email', password: 'password');

if (response.error != null) {
  // Error
  print('Error: ${response.error?.message}');
} else {
  // Success
  final session = response.data;
}

Sign out #

Use the signOut method, which returns a GotrueResponse.

Also for the sign out check that error is null to know if the request was successful.

// Sign out user
final response = await client.auth.signOut();

if (response.error != null) {
  // Error
  print('Error: ${response.error?.message}');
} else {
  // Success
}

Check out the Official Documentation to learn all the other available methods.

Guides #

  • Flutter Supabase Authentication - Blog

Contributing #

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Commit changes to your own branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes and merge

License #

This repo is licenced under MIT.

Credits #

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

License

unknown (license)

Dependencies

gotrue, postgrest, realtime_client, storage_client

More

Packages that depend on supabase