@@ -27,27 +27,29 @@ ClientBase createClient({
2727class ClientIO extends ClientBase with ClientMixin {
2828 String _endPoint;
2929 Map<String , String >? _headers;
30+ @override
3031 late Map<String , String > config;
3132 bool selfSigned;
3233 bool _initialized = false;
3334 String? _endPointRealtime;
3435 late http.Client _httpClient;
3536 late HttpClient _nativeClient;
3637 late CookieJar _cookieJar;
37- List<Interceptor > _interceptors = [];
38+ final List<Interceptor > _interceptors = [];
3839
3940 bool get initialized => _initialized;
4041 CookieJar get cookieJar => _cookieJar;
42+ @override
4143 String? get endPointRealtime => _endPointRealtime;
4244
4345 ClientIO({
4446 String endPoint = 'https://appwrite.io/v1',
4547 this.selfSigned = false,
4648 }) : _endPoint = endPoint {
47- _nativeClient = new HttpClient()
49+ _nativeClient = HttpClient()
4850 ..badCertificateCallback =
4951 ((X509Certificate cert, String host, int port) => selfSigned);
50- _httpClient = new IOClient(_nativeClient);
52+ _httpClient = IOClient(_nativeClient);
5153 _endPointRealtime = endPoint
5254 .replaceFirst('https://', 'wss://')
5355 .replaceFirst('http://', 'ws://');
@@ -66,12 +68,13 @@ class ClientIO extends ClientBase with ClientMixin {
6668 init();
6769 }
6870
71+ @override
6972 String get endPoint => _endPoint;
7073
7174 Future<Directory > _getCookiePath() async {
7275 final directory = await getApplicationDocumentsDirectory();
7376 final path = directory.path;
74- final Directory dir = new Directory('$path/cookies');
77+ final Directory dir = Directory('$path/cookies');
7578 await dir.create();
7679 return dir;
7780 }
@@ -80,20 +83,23 @@ class ClientIO extends ClientBase with ClientMixin {
8083{% if header .description %}
8184 /// {{header .description }}
8285{% endif %}
86+ @override
8387 ClientIO set{{header .key | caseUcfirst }}(value) {
8488 config['{{ header .key | caseCamel }}'] = value;
8589 addHeader('{{header .name }}', value);
8690 return this;
8791 }
8892{% endfor %}
8993
94+ @override
9095 ClientIO setSelfSigned({bool status = true}) {
9196 this.selfSigned = status;
9297 _nativeClient.badCertificateCallback =
9398 ((X509Certificate cert, String host, int port) => status);
9499 return this;
95100 }
96101
102+ @override
97103 ClientIO setEndpoint(String endPoint) {
98104 this._endPoint = endPoint;
99105 _endPointRealtime = endPoint
@@ -102,11 +108,13 @@ class ClientIO extends ClientBase with ClientMixin {
102108 return this;
103109 }
104110
111+ @override
105112 ClientIO setEndPointRealtime(String endPoint) {
106113 _endPointRealtime = endPoint;
107114 return this;
108115 }
109116
117+ @override
110118 ClientIO addHeader(String key, String value) {
111119 _headers![key] = value;
112120
@@ -116,7 +124,7 @@ class ClientIO extends ClientBase with ClientMixin {
116124 Future init() async {
117125 // if web skip cookie implementation and origin header as those are automatically handled by browsers
118126 final Directory cookieDir = await _getCookiePath();
119- _cookieJar = new PersistCookieJar(storage: FileStorage(cookieDir.path));
127+ _cookieJar = PersistCookieJar(storage: FileStorage(cookieDir.path));
120128 this._interceptors.add(CookieManager(_cookieJar));
121129 PackageInfo packageInfo = await PackageInfo.fromPlatform();
122130 addHeader('Origin',
@@ -191,6 +199,7 @@ class ClientIO extends ClientBase with ClientMixin {
191199 return response;
192200 }
193201
202+ @override
194203 Future webAuth(Uri url) {
195204 return FlutterWebAuth.authenticate(
196205 url: url.toString(),
@@ -203,7 +212,7 @@ class ClientIO extends ClientBase with ClientMixin {
203212 throw {{spec .title | caseUcfirst }}Exception(
204213 "Invalid OAuth2 Response. Key and Secret not available.", 500);
205214 }
206- Cookie cookie = new Cookie(key, secret);
215+ Cookie cookie = Cookie(key, secret);
207216 cookie.domain = Uri.parse(_endPoint).host;
208217 cookie.httpOnly = true;
209218 cookie.path = '/';
@@ -213,6 +222,7 @@ class ClientIO extends ClientBase with ClientMixin {
213222 });
214223 }
215224
225+ @override
216226 Future<Response > call(
217227 HttpMethod method, {
218228 String path = '',
0 commit comments