File tree 1 file changed +9
-0
lines changed
packages/supabase_flutter/lib/src
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1
1
import 'dart:io' ;
2
2
3
3
import 'package:cupertino_http/cupertino_http.dart' ;
4
+ import 'package:flutter/widgets.dart' ;
4
5
import 'package:http/http.dart' as http;
5
6
import 'package:supabase_flutter/supabase_flutter.dart' ;
6
7
import 'package:web_socket_channel/adapter_web_socket_channel.dart' ;
@@ -11,6 +12,7 @@ import 'package:web_socket_channel/web_socket_channel.dart';
11
12
///
12
13
/// This is used to make HTTP requests use the platform's native HTTP client.
13
14
http.Client getPlatformHttpClient () {
15
+ if (isInWidgetTest) return http.Client ();
14
16
if (Platform .isIOS || Platform .isMacOS) {
15
17
return CupertinoClient .defaultSessionConfiguration ();
16
18
} else {
@@ -24,9 +26,16 @@ http.Client getPlatformHttpClient() {
24
26
/// It may return `null` because the differentiation for the other platforms
25
27
/// is done in [RealtimeClient] .
26
28
WebSocketChannel Function (String url)? getPlatformWebSocketChannel () {
29
+ if (isInWidgetTest) return null ;
27
30
if (Platform .isIOS || Platform .isMacOS) {
28
31
return (String url) =>
29
32
AdapterWebSocketChannel (CupertinoWebSocket .connect (Uri .parse (url)));
30
33
}
31
34
return null ;
32
35
}
36
+
37
+ bool get isInWidgetTest {
38
+ return WidgetsBinding .instance.runtimeType
39
+ .toString ()
40
+ .contains ('TestWidgetsFlutterBinding' );
41
+ }
You can’t perform that action at this time.
0 commit comments