Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.

Overview

supabase_flutter

Flutter package 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

Status

  • Alpha: Under heavy development
  • Public Alpha: Ready for testing. But go easy on us, there will be bugs and missing functionality.
  • Public Beta: Stable. No breaking changes expected in this version but possible bugs.
  • Public: Production-ready

Getting Started

Import the package:

import 'package:supabase_flutter/supabase_flutter.dart';

Intialize Supabase before using it:

import 'package:supabase_flutter/supabase_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  Supabase.initialize(
    url: SUPABASE_URL,
    anonKey: SUPABASE_ANNON_KEY,
    authCallbackUrlHostname: 'login-callback', // optional
    debug: true // optional
  );

  runApp(MyApp());
}

authCallbackUrlHostname is optional. It will be used to filter Supabase authentication redirect deeplink. You need to provide this param if you use deeplink for other features on the app.

debug is optional. It's enabled by default if you're running the app in debug mode (flutter run --debug).

Authentication

Using authentication can be done easily.

Email authentication

import 'package:supabase_flutter/supabase_flutter.dart';

void signIn(String email, String password) async {
  final response = await Supabase.instance.client.auth.signIn(email: _email, password: _password);
  if (reponse.error != null) {
    /// Handle error
  } else {
    /// Sign in with success
  }
}

SupabaseAuthState

It helps you handle authentication with deeplink from 3rd party service like Google, Github, Twitter...

For more details, take a look at the example here

When using with a nested authentication flow, remember to call startAuthObserver() and stopAuthObserver() before/after navigation to new screen to prevent multiple observers running at the same time. Take a look at the example here

SupabaseAuthRequiredState

It helps you protect route that requires an authenticated user.

For more details, take a look at the example here

signInWithProvider

This method will automatically launch the auth url and open a browser for user to sign in with 3rd party login.

Supabase.instance.client.auth.signInWithProvider(
  Provider.github,
  options: supabase.AuthOptions(redirectTo: ''),
);

Custom LocalStorage

As default supabase_flutter uses hive plugin to persist user session. However you can use any other plugins by creating a LocalStorage impl.

For example, we can use flutter_secure_storage plugin to store the user session in a secure storage.

// Define the custom LocalStorage implementation
class SecureLocalStorage extends LocalStorage {
  SecureLocalStorage() : super(
    initialize: () async {},
    hasAccessToken: () {
      const storage = FlutterSecureStorage();
      return storage.containsKey(key: supabasePersistSessionKey);
    }, accessToken: () {
      const storage = FlutterSecureStorage();
      return storage.read(key: supabasePersistSessionKey);
    }, removePersistedSession: () {
      const storage = FlutterSecureStorage();
      return storage.delete(key: supabasePersistSessionKey);
    }, persistSession: (String value) {
      const storage = FlutterSecureStorage();
      return storage.write(key: supabasePersistSessionKey, value: value);
    },
  );
}

// use it when initializing
Supabase.initialize(
  ...
  localStorage: SecureLocalStorage(),
);

You can use EmptyLocalStorage to disable session persistance:

Supabase.initialize(
  ...
  localStorage: const EmptyLocalStorage(),
);

Deeplink config

Supabase redirect URLs config

  • Go to your Supabase project Authentication Settings page.
  • You need to enter your app redirect callback on Additional Redirect URLs field.

The redirect callback url should have this format [YOUR_SCHEME]://[YOUR_AUTH_HOSTNAME]

authentication settings page

Supabase 3rd party logins config

Follow the guide https://supabase.io/docs/guides/auth#third-party-logins

For Android

Deep Links can have any custom scheme. The downside is that any app can claim a scheme, so make sure yours are as unique as possible, eg. HST0000001://host.com.

<manifest ...>
  <!-- ... other tags -->
  <application ...>
    <activity ...>
      <!-- ... other tags -->

      <!-- Deep Links -->
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
        <data
          android:scheme="[YOUR_SCHEME]"
          android:host="[YOUR_HOST]" />
      </intent-filter>
    </activity>
  </application>
</manifest>

The android:host attribute is optional for Deep Links.

For more info: https://developer.android.com/training/app-links/deep-linking

For iOS

Custom URL schemes can have... any custom scheme and there is no host specificity, nor entitlements or a hosted file. The downside is that any app can claim any scheme, so make sure yours is as unique as possible, eg. hst0000001 or myIncrediblyAwesomeScheme.

For Custom URL schemes you need to declare the scheme in ios/Runner/Info.plist (or through Xcode's Target Info editor, under URL Types):

<!-- ... other tags -->
<plist>
<dict>
  <!-- ... other tags -->
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>[YOUR_SCHEME]</string>
      </array>
    </dict>
  </array>
  <!-- ... other tags -->
</dict>
</plist>

This allows for your app to be started from YOUR_SCHEME://ANYTHING links.

For more info: https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app


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.

Comments
  • Login/Signup on web not working

    Login/Signup on web not working

    I'm using supabase for my flutter app, and I've started the web app, the problem is that when I login (with magic link or provider) the user is not authenticated and if I refresh the page there is the error 'no access_token detected', I've tried also to download your flutter project and run on web, and I ha the same Issue.

    I'm not passing redirect url to the Auth option.

    auth 
    opened by fabios9702 40
  • How generate right credentials for  Google Sign-in?

    How generate right credentials for Google Sign-in?

    In my flutter project which is for both Android and iOS, I want to implement authentication with Google. Supabase wants from me the Client ID and Client secret. When I go to the Google Cloud Platform and try to generate an OAuth Client ID, it asks from me the project type(Web, Android, iOS).

    1. What type should I select, if my project is for both Android and iOS, but Supabase asks from me only one Client ID and Client secret.
    2. For example if I select Android, it gives me only Client ID, not client secret, but Supabase waits from me both.
    3. Then I selected web application, and filled the client id and client secret fields in Supabase google sign in credentials. But when I try to sign in with Provider.Google in supabase, it in the same moment returns null data.

    p.s. Even consent screen is not opening

    opened by hmarat 30
  • Flutter Web Login

    Flutter Web Login

    Hi there, I am trying to integrate Supabase with the flutter App. I am using plugin url_strategy to remove # from the flutter URL. https://pub.dev/packages/url_strategy/

    But when I get Supabase call back it starts with # so the flutter web router also removes that URL. Is there any we can get call back URL without #?

    documentation auth 
    opened by nomanmurtaza786 27
  • Unknown return type

    Unknown return type

    Describe the bug

    Missing variable type for 'data'.

    Try adding an explicit type, or remove implicit-dynamic from your analysis options file.

    The Dart analyzer shows this error in both pieces of code below in an environment where implicit-dynamics: false is set. It is impossible to even run the app because of this error. I cannot use supabase 1.0.0 or above until it is fixed.

    Code from README of the supabase package:

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

    Code from README of the postgrest package:

    final url = 'https://example.com/postgrest/endpoint';
    final client = PostgrestClient(url);
    final response = await client.from('users').select();
    

    To Reproduce

    Steps to reproduce the behavior:

    1. Enable the strong mode by adding some settings to analysis_options.yaml. (See the bottom of this report.)
    2. Paste the code above in the editor of an IDE.
    3. See the error.

    Expected behavior

    There is no error mentioned above.

    Screenshots

    supabase_bug

    Smartphone (please complete the following information):

    • Version [e.g. 1.0.0-dev.4]
      • What do "Smartphone" and "1.0.0-dev.4" mean here? If it's about the package version, I found this bug in supabase 1.0.1.

    Additional context

    • Packages should be developed with stricter rules about types, otherwise its users will likely get into trouble.
      • e.g.
        analyzer:
          strong-mode:
            implicit-casts: false
            implicit-dynamic: false
        
    • I'm currently experiencing this error in postgrest, but I think it would be better to see if other supabase packages have the same issue and improve them if any.
    bug 
    opened by kaboc 26
  • Error into realtime _isTargetRecord method

    Error into realtime _isTargetRecord method

    This method handle realtime Update and Delete events checking payload['eventType'] the problem is that this key is not present into payload but should be payload['type']

      bool _isTargetRecord({
        required Map<String, dynamic> record,
        required Map<String, dynamic> payload,
      }) {
        late final Map<String, dynamic> targetRecord;
        if (payload['eventType'] == 'UPDATE') {    <--- THE PROBLEM IS THERE
          targetRecord = payload['new']!;
        } else if (payload['eventType'] == 'DELETE') {     <--- AND THERE
          targetRecord = payload['old']!;
        }
        return _uniqueColumns
            .every((column) => record[column] == targetRecord[column]);
      }
    

    Regards

    bug 
    opened by ISIGest 25
  • The authenticated user get logout after a hour

    The authenticated user get logout after a hour

    Authentication Bug

    If user is not connected to internet and open app after a hour or two, the supabase.auth.user is null so the app show the login screen to user again.

    To Reproduce

    1. Run the quick start example
    2. Close the app
    3. Open app after hour or two with no internet connection
    4. The supabase.auth.user which is current user will be null
    bug auth 
    opened by iampopal 25
  • returning data from stream in flutter

    returning data from stream in flutter

    doesn't work listening to a specific column.

    My Table; database columns(category5) = (category5_id,name,fk_category4_id)

    My code is;

    db.supabase
    .from('category5:fk_category4_id=eq.${selectCategory5!.keys.first}')
    .stream(['category5_id,name']).execute();
    
    return data => all columns.
    
    bug realtime 
    opened by yutech23 22
  • BREAKING: Remove SupabaseAuthRequiredState as well as overriding methods in SupabaseAuthState

    BREAKING: Remove SupabaseAuthRequiredState as well as overriding methods in SupabaseAuthState

    Comments are welcome!

    This is just a proposal in an attempt to improve developer experience of this library.

    Current behavior

    Currently, there are SupabaseAuthState and SupabaseAuthRequiredState. A lot of their functionalities overlap, and having two different classes might be confusing.

    Also, SupabaseAuthState have the following methods, but users don't necessary need all of them if they are using SupabaseAuthState just for auth state persistance.

      /// Callback when deeplink received and is processing. Optional
      void onReceivedAuthDeeplink(Uri uri) {
        Supabase.instance.log('onReceivedAuthDeeplink uri: $uri');
      }
    
      /// Callback when user is unauthenticated
      void onUnauthenticated();
    
      /// Callback when user is authenticated
      void onAuthenticated(Session session);
    
      /// Callback when authentication deeplink is recovery password type
      void onPasswordRecovery(Session session);
    
      /// Callback when recovering session from authentication deeplink throws error
      void onErrorAuthenticating(String message);
    

    New behavior

    All of the classes that were inheriting State has been removed, and deeplinking and auth state persistence logic has been consolidated into SupabaseAuth class.

    Instead of relying on onAuthenticated() and onUnauthenticated(), users can utilize Supabase.instance.client.auth.onAuthStateChange() to navigate users to different routes depending on Auth state.

    opened by dshukertjr 20
  • No access_token detected (orj. example)

    No access_token detected (orj. example)

    I USE autH.signInWithPassword()

    I upgraded 1.1.0 version. I got a error. it's "No access_token detected. I have tried example in git but I got same error. Please Help can

    image

    bug 
    opened by yutech23 19
  • Data Not Being Sent When Using supabase.auth.signInWithOtp

    Data Not Being Sent When Using supabase.auth.signInWithOtp

    When trying to using the supabase.auth.signInWithOtp for Magic link along with passing user data. the data is sent as null.

    await supabase.auth.signInWithOtp(
                  email: email,
                  emailRedirectTo: kIsWeb
                      ? null
                      : 'com.socialjawn.supabase.test://login-callback/',
                  data: {
                    'firstname': _firstName!.trim(),
                    'lastname': _lastName!.trim(),
                    'username': username!.trim(),
                    'gender': _gender!.trim(),
                    'pronoun': _pronoun!.trim(),
                    'dateofbirth': bday!.toIso8601String(),
                  },
                );
    

    I am using version 1.0 Using a Pixel 7 Pro

    [✓] Flutter (Channel stable, 3.3.5, on macOS 12.6 21G115 darwin-arm, locale
        en-US)
        • Flutter version 3.3.5 on channel stable at
          /Users/rickeylee/Desktop/dev/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision d9111f6402 (24 hours ago), 2022-10-19 12:27:13 -0700
        • Engine revision 3ad69d7be3
        • Dart version 2.18.2
        • DevTools version 2.15.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version
        33.0.0-rc1)
        • Android SDK at /Users/rickeylee/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc1
        • ANDROID_HOME = /Users/rickeylee/Library/Android/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build
          11.0.12+0-b1504.28-7817840)
    
    [✓] VS Code (version 1.72.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] Connected device (5 available)
        • Pixel 7 Pro (mobile)         • 28181FDH300KGN                           • android-arm64  • Android 13 (API 33)
        • SM N950U (mobile)            • ce061716d1923703017e                     • android-arm64  • Android 9 (API 28)
        • rickey lee’s iPhone (mobile) • d0545eb2ff26e1c087d1b29c26f8e15da19284bb • ios            • iOS 16.0 20A362
        • macOS (desktop)              • macos                                    • darwin-arm64   • macOS 12.6 21G115 darwin-arm
        • Chrome (web)                 • chrome                                   • web-javascript • Google Chrome 106.0.5249.119
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    bug auth 
    opened by rlee1990 19
  • Weird errors related to connecting to the Supabase instance in Flutter

    Weird errors related to connecting to the Supabase instance in Flutter

    Hi,

    I've been sent here by Div of the support team.

    I'm experiencing frequent and weird errors related to connecitng to my Supabase instance from my Flutter app.

    Some examples:

    • ClientException: Can't assign requested address
    • SocketException: Failed host lookup: 'DOMAIN.supabase.in' (OS Error: No address associated with hostname, errno = 7)
    • Connection closed before full header was received
    • SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = DOMAIN.supabase.in, port = 39244
    • ClientException: Bad file descriptor
    • ClientException: Operation timed out

    I'm completely in the dark about what, and have the feeling that it is not my code which, causes this. Anyone with some insights into this or that can help me?

    opened by deliqs 17
  • fix: Minor typo in README

    fix: Minor typo in README

    What kind of change does this PR introduce?

    Fixes a minor typo in the readme, ANNON => ANON

    What is the current behavior?

    Behaviour doesn't change.

    What is the new behavior?

    Behaviour doesn't change.

    opened by spydon 0
  • Listen to data using the .eq filter not working properly

    Listen to data using the .eq filter not working properly

    Describe the bug Maybe I am missing something, but there seems to be a bug when using the .eq filter in streaming data via realtime.

    To Reproduce Steps to reproduce the behavior:

    1. Create a table with at least one additional column (I set it to type boolean and called it col)
    2. Add some mock data
    3. Use the SDK to retrieve data with an .eq filter: supabase.from('example').stream(primaryKey: ['id']).eq('col', true);

    Expected behavior Lets say there are 2 rows where col is true. These two are delivered to the device and an event is registered everytime something changes in these rows. So far so good. But: If a different row gets col set to true, the SDK throws the following error: Unhandled Exception: Exception: Could not find the updated record. The expected behavior would be for the SDK to deliver 3 rows.

    Furthermore, if a row A that previously had col = true gets set to col = false, there is no event emitted. Additionally, if something changes in a row where col is still set to true, the row A will still be emitted in the event, but in the state before col was set to false.

    Smartphone (please complete the following information): Version: supabase_flutter: ^1.2.1

    Additional context Complete error message: E/flutter (10388): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Could not find the updated record. E/flutter (10388): #0 SupabaseStreamBuilder._addException (package:supabase/src/supabase_stream_builder.dart:404:67) E/flutter (10388): #1 SupabaseStreamBuilder._getStreamData. (package:supabase/src/supabase_stream_builder.dart:295:9) E/flutter (10388): #2 RealtimeChannel.trigger (package:realtime_client/src/realtime_channel.dart:559:22) E/flutter (10388): #3 RealtimeClient.onConnMessage.. (package:realtime_client/src/realtime_client.dart:294:41) E/flutter (10388): #4 Iterable.forEach (dart:core/iterable.dart:325:35) E/flutter (10388): #5 RealtimeClient.onConnMessage. (package:realtime_client/src/realtime_client.dart:294:12) E/flutter (10388): #6 new RealtimeClient. (package:realtime_client/src/realtime_client.dart:100:21) E/flutter (10388): #7 RealtimeClient.onConnMessage (package:realtime_client/src/realtime_client.dart:277:11) E/flutter (10388): #8 RealtimeClient.connect. (package:realtime_client/src/realtime_client.dart:125:22) E/flutter (10388): #9 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) E/flutter (10388): #10 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) E/flutter (10388): #11 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (10388): #12 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11) E/flutter (10388): #13 _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10) E/flutter (10388): #14 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13) E/flutter (10388): #15 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) E/flutter (10388): #16 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) E/flutter (10388): #17 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (10388): #18 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19) E/flutter (10388): #19 _StreamController._add (dart:async/stream_controller.dart:648:7) E/flutter (10388): #20 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) E/flutter (10388): #21 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) E/flutter (10388): #22 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (10388): #23 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19) E/flutter (10388): #24 _StreamController._add (dart:async/stream_controller.dart:648:7) E/flutter (10388): #25 _StreamController.add (dart:async/stream_controller.dart:596:5) E/flutter (10388): #26 new _WebSocketImpl._fromSocket. (dart:_http/websocket_impl.dart:1144:21) E/flutter (10388): #27 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) E/flutter (10388): #28 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) E/flutter (10388): #29 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (10388): #30 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11) E/flutter (10388): #31 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11) E/flutter (10388): #32 _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23) E/flutter (10388): #33 _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46) E/flutter (10388): #34 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24) E/flutter (10388): #35 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) E/flutter (10388): #36 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) E/flutter (10388): #37 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (10388): #38 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19) E/flutter (10388): #39 _StreamController._add (dart:async/stream_controller.dart:648:7) E/flutter (10388): #40 _StreamController.add (dart:async/stream_controller.dart:596:5) E/flutter (10388): #41 _Socket._onData (dart:io-patch/socket_patch.dart:2324:41) E/flutter (10388): #42 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10) E/flutter (10388): #43 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) E/flutter (10388): #44 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (10388): #45 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19) E/flutter (10388): #46 _StreamController._add (dart:async/stream_controller.dart:648:7) E/flutter (10388): #47 _StreamController.add (dart:async/stream_controller.dart:596:5) E/flutter (10388): #48 _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1107:19) E/flutter (10388): #49 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15) E/flutter (10388): #50 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19) E/flutter (10388): #51 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5) E/flutter (10388): #52 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

    bug 
    opened by jvlt 4
  • New token refresh algorithm  on gotrue-js

    New token refresh algorithm on gotrue-js

    *Posting this without reading too much into the context, so might not be relevant for us, but wanted to get it out there for visibility.

    Gotrue-js is updating their token refresh algorithm, here. Might be something worth looking into! https://github.com/supabase/gotrue-js/pull/564

    Personally, I think the current implementation is okay though unless someone knows any issues.

    enhancement auth 
    opened by dshukertjr 1
  • initialize client with multiple schemas

    initialize client with multiple schemas

    Flutter client doesn't seem to support initializing Supabase with multiple schemas and then querying based on those schemas. One client = one schema.

    the code below throws this error This instance is already initialized

    var schemaOne = await Supabase.initialize(url: endpoint, anonKey: anonKey, schema: 'schema_one', debug: kDebugMode);
    var schemaTwo = await Supabase.initialize(url: endpoint, anonKey: anonKey, schema: 'schema_two', debug: kDebugMode);
    
    1. A workaround for this is to dispose of the client and re-init it every time a new query is made to a different schema. IMO this doesn't sound that good. I guess it raises some performance issues and other side effects, but maybe not and that's the intended behavior.

    2. Another workaround would be to not use the Supabase.initialize() method and init the SupabaseClient directly:

    await SupabaseAuth.initialize();
    var schemaOne = SupabaseClient(url, anonKey, schema: 'schema_one');
    var schemaTwo = SupabaseClient(url, anonKey, schema: 'schema_two');
    

    This is a bit of a hack also, this way the log() method from Supabase class doesn't know about the _debugEnable flag. Is there another way of doing this?

    Edit: I tried solution 2 and it doesn't work. Supabase.initialize() must be called, so the way I did it is to call that method which initializes Supabase with the default scheme - public and then separately initialize other schemas with SupabaseClient()

    enum SupabaseSchemas { public, schema1, schema2 }
    
    late final Map<SupabaseSchemas, SupabaseClient> schemas = {};
    
    Future<void> _initSchemas() async {
        schemas[SupabaseSchemas.public] = (await Supabase.initialize(url: endpoint, anonKey: anonKey, debug: kDebugMode)).client;
        final List<SupabaseSchemas> customSchemas = SupabaseSchemas.values.filterNot((sch) => sch == SupabaseSchemas.public).toList();
    
        for (final schema in customSchemas) {
          schemas[schema] = schemas[schema] == null || schemas[schema] is! SupabaseClient
              ? (SupabaseClient(endpoint, anonKey, schema: schema.name))
              : schemas[schema]!;
        }
      }
    

    Currently, the above solution seems to work, but I'm not sure if this is the proper way to do it or if there's another way of doing this. An ideal solution would be to init the client with the custom schemas and then for every query to be able to set the schema as an option.

    enhancement 
    opened by chirastefan 0
  • Using OAuth causes App Store Rejection (iOS only)

    Using OAuth causes App Store Rejection (iOS only)

    Describe the bug This is not actually a bug but a critical issue to report. The current OAuth flow for iOS of Supabase is not acceptable in the App Store. My app has been rejected because the supabase-flutter SDK OAuth flow opens in an external browser instead of the in-app Safari web view controller as they suggested.

    To Reproduce Submit your iOS Flutter app to the app store with OAuth sign in

    Expected behavior Get approved

    Screenshots NexSnap-Dec-18-2022_05-50-54_AM

    Smartphone (please complete the following information):

    • Version 16.2 iPhone 14 Max (simulator)

    Additional context Because of this, I am stuck. I cannot publish new versions of my app. The only workaround for me right now is to use Magic Links or regular username, and password sign-ups which is not a great experience.

    bug 
    opened by oliverbytes 3
  • Making The Presence Class Accessible

    Making The Presence Class Accessible

    It would be nice if the presence class was accessible and if the presenceState was of a type and not just dynamic. This would make it easier on the devolopers.

    enhancement 
    opened by rlee1990 0
Owner
Supabase
Supabase
Flutter package for displaying and animating Scalable Vector Graphics 1.1 files. The package has been written solely in Dart Language.

Animated SVG | Flutter Package Flutter package for displaying and animating Scalable Vector Graphics 1.1 files. The package has been written solely in

Bulent Baris Kilic 5 Jul 19, 2022
The Dart client for Teta CMS. Our mission is to help people build amazing products.

Teta CMS The Dart client for Teta CMS Introducing Teta CMS Teta CMS is a low-code back-end service. We provide: Scalable NoSQL database Real-time subs

Teta.so 101 Dec 22, 2022
Flutter-fb-integration - Flutter And firebase integration Guide

Quickstart Guide This project still use my firebase server config, if you want t

Naufal Aldy Pradana 0 Feb 2, 2022
Getx and Dio APi-Integration - Flutter RestApi Integration using Dio

Flutter RestApi Integration using Dio. Click this image to find videos==> //Crud

Fsd Ramjan 9 Nov 5, 2022
FLutter Api Integration - Flutter Rest API Integration

Flutter_Rest_Api_integration Flutter_Rest_Api_integration. Preview How To Use To

Rahul Ranjan Singh 0 Feb 17, 2022
Integration test - Copy of the official Flutter integration test plugin

integration_test This package enables self-driving testing of Flutter code on de

null 0 Jan 5, 2022
Flutter template project - Simple ToDo app with scalable project structure.

Flutter Template Flutter template project - A simple TODO list app. This template provides simple UI and scalable project structure that goes beyond t

Web Factory LLC 128 Nov 21, 2022
DEVS: Developer Board and Jobs Listing | For Developers, By Developers

devs Setup Currently, this DEVS project is using the master channel of the Flutter SDK. TODO: Migrate to beta Clone the project git clone https://gith

Flutter Philippines Community 40 Apr 16, 2022
A beautiful, secure and simple authenticator app that supports multiple protocols and services. Free and open source. Written in Flutter and Dart.

OpenAuth A beautiful, secure and simple authenticator app that supports multiple protocols and services. Free and open source. Written in Flutter and

Isaiah Collins Abetong 31 Oct 5, 2022
Dartness is a progressive dart framework for building efficient and scalable server-side applications

Dartness is a framework for building efficient, scalable dart server-side applications. It provides an easy and quick way to develop modern standalone server.

Ricardo Romero 33 Dec 12, 2022
🦜 Parrot - A progressive Dart framework for building efficient, reliable and scalable server-side applications.

?? Parrot A progressive Dart framework for building efficient, reliable and scalable server-side applications. What is Parrot? Parrot is a Dart framew

Odroe 8 Nov 11, 2022
This is a university marketplace, where students buy and sell products and services online or offline. Mainly to connect the two parties together.

marktorder A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Ibukunoluwa Naphtali 1 Jan 10, 2022
Let's setup Firebase​​ for our Flutter​​ app on Android​, iOS​ and Flutter Web. Setup Firebase to use Firebase products.

Flutter Tutorial - Firebase Setup For Flutter Web Let's setup Firebase for our Flutter app on Android, iOS and Flutter Web. Setup Firebase to use Fire

null 1 Apr 27, 2022
A modular app architecture that can be scalable as the time passes

A modular app architecture that can be scalable as the time passes. I will be using the BLoC state-management package.

Md. Siam 62 Dec 25, 2022
mypro immobilier app created to manage our real estate agency, we can store products, contacts and transactions..

mypro_immobilier A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

soufiane bouchtaoui 1 Dec 11, 2021
A Rick and Morty Character Wiki, build in Flutter with Api Rest integration.

Rick and Morty Character Wiki This is an app build in Flutter that loads a list of characters (from the serie Rick and Morty) and his info, and displa

Jessica Aidyl 3 Jul 27, 2022
A renting platform to rent products

Welcome to RentALL Mobile App ?? A renting platform to rent products APP PREVIEW Install flutter create . Usage flutter run Run tests f5 / debug ?? Ak

Akshat Sachan 24 Aug 19, 2022
Here is an application project that displays a list of products from the Elevenia API called STORE.

Here is an application project that displays a list of products from the Elevenia API called STORE.

Dedi Kurniawan 2 May 18, 2022
Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing

Flutter 148.2k Jan 8, 2023