Skip to content

Commit 988ac08

Browse files
committed
Bug fix
1 parent 66b5f48 commit 988ac08

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.2
2+
3+
- Fixed an error that happend when the OAuth session creation request was sent before any other API call
4+
-
15
## 0.2.1
26

37
- Fixed callback scheme

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
[![pub package](https://img.shields.io/pub/v/appwrite.svg)](https://pub.dartlang.org/packages/appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?v=1)
5-
![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1)
5+
![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.svg?v=1)
66

7-
**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.**
7+
**This SDK is compatible with Appwrite server version 0.6.1. For older versions, please check previous releases.**
88

99
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
1010
Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
@@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file:
2020

2121
```yml
2222
dependencies:
23-
appwrite: ^0.2.1
23+
appwrite: ^0.2.2
2424
```
2525
2626
You can install packages from the command line:

lib/client.dart

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Client {
1515
Map<String, String> headers;
1616
Map<String, String> config;
1717
bool selfSigned;
18-
bool init = false;
18+
bool initialized = false;
1919
Dio http;
2020
PersistCookieJar cookieJar;
2121

@@ -30,7 +30,7 @@ class Client {
3030

3131
this.headers = {
3232
'content-type': 'application/json',
33-
'x-sdk-version': 'appwrite:dart:0.2.1',
33+
'x-sdk-version': 'appwrite:dart:0.2.2',
3434
};
3535

3636
this.config = {};
@@ -76,6 +76,22 @@ class Client {
7676
return this;
7777
}
7878

79+
Future init() async {
80+
if(!initialized) {
81+
final Directory cookieDir = await _getCookiePath();
82+
83+
cookieJar = new PersistCookieJar(dir:cookieDir.path);
84+
85+
this.http.options.baseUrl = this.endPoint;
86+
this.http.options.validateStatus = (status) => status < 400;
87+
this.http.interceptors.add(CookieManager(cookieJar));
88+
89+
PackageInfo packageInfo = await PackageInfo.fromPlatform();
90+
91+
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
92+
}
93+
}
94+
7995
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
8096
if(selfSigned) {
8197
// Allow self signed requests
@@ -85,21 +101,7 @@ class Client {
85101
};
86102
}
87103

88-
if(!init) {
89-
final Directory cookieDir = await _getCookiePath();
90-
91-
cookieJar = new PersistCookieJar(dir:cookieDir.path);
92-
93-
this.http.options.baseUrl = this.endPoint;
94-
this.http.options.validateStatus = (status) => status < 400;
95-
this.http.interceptors.add(CookieManager(cookieJar));
96-
97-
PackageInfo packageInfo = await PackageInfo.fromPlatform();
98-
99-
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
100-
101-
init = true;
102-
}
104+
await this.init();
103105

104106
// Origin is hardcoded for testing
105107
Options options = Options(

lib/services/account.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,10 @@ class Account extends Service {
325325
return FlutterWebAuth.authenticate(
326326
url: url.toString(),
327327
callbackUrlScheme: "appwrite-callback-" + client.config['project']
328-
).then((value) {
328+
).then((value) async {
329329
Uri url = Uri.parse(value);
330330
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
331+
await client.init();
331332
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
332333
});
333334
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: appwrite
2-
version: 0.2.1
2+
version: 0.2.2
33
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
44
homepage: https://appwrite.io
55
repository: https://github.com/appwrite/sdk-for-flutter

0 commit comments

Comments
 (0)