Skip to content

Commit c389ec1

Browse files
Showcase how to provide custom HTTP client
1 parent b37fec0 commit c389ec1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

example/lib/main.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:http/http.dart' as http;
12
import 'dart:async' show StreamSubscription;
23
import 'dart:io';
34
import 'dart:convert';
@@ -22,6 +23,18 @@ ColorScheme colorSchemeFromContext(BuildContext context) {
2223
}
2324
}
2425

26+
class MyHTTPClient extends http.BaseClient {
27+
final http.Client _inner;
28+
29+
MyHTTPClient(this._inner);
30+
31+
@override
32+
Future<http.StreamedResponse> send(http.BaseRequest request) {
33+
request.headers["x-custom-header"] = "42";
34+
return _inner.send(request);
35+
}
36+
}
37+
2538
void main() {
2639
if (Platform.isIOS) {
2740
wechatRedirectURI =
@@ -917,6 +930,7 @@ class _MyAppState extends State<MyApp> {
917930
),
918931
)
919932
: null,
933+
httpClient: MyHTTPClient(http.Client()),
920934
);
921935
_sub?.cancel();
922936
await authgear.configure();

0 commit comments

Comments
 (0)