File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -22,20 +22,20 @@ class EmailJS {
22
22
static String _host = 'api.emailjs.com' ;
23
23
24
24
/// HTTP Client specified in the [init] method
25
- static http.Client _httpClient = http. Client () ;
25
+ static http.Client ? _httpClient;
26
26
27
27
/// Global configuration for EmailJS
28
28
///
29
29
/// Sets globally the EmailJS [options]
30
30
static void init (
31
31
Options options, [
32
32
String ? host,
33
- http.Client ? httpClient ,
33
+ http.Client ? customHttpClient ,
34
34
]) {
35
35
EmailJS ._publicKey = options.publicKey;
36
36
EmailJS ._privateKey = options.privateKey;
37
37
EmailJS ._host = host ?? 'api.emailjs.com' ;
38
- EmailJS ._httpClient = httpClient ?? http. Client () ;
38
+ EmailJS ._httpClient = customHttpClient ;
39
39
}
40
40
41
41
/// Sends the email through the [serviceID] using the ready-made [templateID] .
@@ -63,9 +63,9 @@ class EmailJS {
63
63
};
64
64
65
65
return await sendJSON (
66
- EmailJS ._httpClient,
67
66
Uri .https (EmailJS ._host, 'api/v1.0/email/send' ),
68
67
json.encode (params),
68
+ EmailJS ._httpClient,
69
69
);
70
70
}
71
71
}
Original file line number Diff line number Diff line change @@ -3,9 +3,12 @@ import '../models/emailjs_response_status.dart';
3
3
4
4
/// sends JSON object via HTTP POST
5
5
Future <EmailJSResponseStatus > sendJSON (
6
- http.Client client, Uri uri, String data) async {
6
+ Uri uri, String data, http.Client ? customClient) async {
7
+
8
+ final client = customClient ?? http.Client ();
9
+
7
10
try {
8
- var response = await client.post (
11
+ final response = await client.post (
9
12
uri,
10
13
headers: {
11
14
'Content-Type' : 'application/json' ,
You can’t perform that action at this time.
0 commit comments