Skip to content

Commit

Permalink
feat: custom http client
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Aug 2, 2022
1 parent b2a89a9 commit d496769
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/src/supabase.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:http/http.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 @@ -43,12 +44,17 @@ class Supabase {
String? authCallbackUrlHostname,
bool? debug,
LocalStorage? localStorage,
Client? httpClient,
}) async {
assert(
!_instance._initialized,
'This instance is already initialized',
);
_instance._init(url, anonKey);
_instance._init(
url,
anonKey,
httpClient: httpClient,
);
_instance._debugEnable = debug ?? kDebugMode;
_instance.log('***** Supabase init completed $_instance');

Expand Down Expand Up @@ -76,10 +82,11 @@ class Supabase {
_initialized = false;
}

void _init(String supabaseUrl, String supabaseAnonKey) {
void _init(String supabaseUrl, String supabaseAnonKey, {Client? httpClient}) {
client = SupabaseClient(
supabaseUrl,
supabaseAnonKey,
httpClient: httpClient,
);
_initialized = true;
}
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ dependencies:
sdk: flutter
hive: ^2.2.1
hive_flutter: ^1.1.0
supabase: ^1.0.0-dev.1
http: ^0.13.4
supabase: ^1.0.0-dev.2
url_launcher: ^6.1.2

dev_dependencies:
Expand Down

0 comments on commit d496769

Please sign in to comment.