Skip to content

Commit

Permalink
Merge pull request supabase#125 from Vinzent03/re-initialize-instance
Browse files Browse the repository at this point in the history
fix: re-initialize client
  • Loading branch information
dshukertjr committed Jul 24, 2022
2 parents 59cc270 + 8e35c8e commit 3093f70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/src/supabase.dart
@@ -1,6 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:supabase/supabase.dart';

import 'package:supabase_flutter/src/local_storage.dart';
import 'package:supabase_flutter/src/supabase_auth.dart';

Expand Down Expand Up @@ -71,7 +70,7 @@ class Supabase {
/// The supabase client for this instance
///
/// Throws an error if [Supabase.initialize] was not called.
late final SupabaseClient client;
late SupabaseClient client;
bool _debugEnable = false;

/// Dispose the instance to free up resources.
Expand Down
13 changes: 12 additions & 1 deletion test/supabase_flutter_test.dart
@@ -1,5 +1,4 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:supabase_flutter/supabase_flutter.dart';

import 'widget_test_stubs.dart';
Expand All @@ -22,6 +21,18 @@ void main() {
expect(client, isNotNull);
});

test('can re-initialize client', () async {
final client = Supabase.instance.client;
Supabase.instance.dispose();
final newClient = (await Supabase.initialize(
url: supabaseUrl,
anonKey: supabaseKey,
localStorage: MockLocalStorage(),
))
.client;
expect(client, isNot(newClient));
});

test('can parse deeplink', () async {
final uri = Uri.parse(
"io.supabase.flutterdemo://login-callback#access_token=aaa&expires_in=3600&refresh_token=bbb&token_type=bearer&type=recovery",
Expand Down

0 comments on commit 3093f70

Please sign in to comment.