Skip to content

Commit 2e25140

Browse files
Merge pull request #26 from appwrite/dev
feat: update version
2 parents 3579314 + 10564f5 commit 2e25140

File tree

11 files changed

+110
-60
lines changed

11 files changed

+110
-60
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.7.0
2+
- Support for Appwrite 0.9
3+
- Breaking - removed order type enum, now you should pass string 'ASC' or 'DESC'
4+
- Image Crop Gravity support in image preview service
5+
- New endpoint in Account getSession to get session by ID
6+
- Fix - issues with User-Agent when app name consisted of non-ASCII characters
7+
- Fix - issue with null Success and Failure URL in createOAuth2Session
8+
- Updated underlying dependencies
9+
110
## 0.6.3
211

312
- Removed default values, nothing should change in usage as default values are already allocated in server
@@ -116,4 +125,4 @@
116125
## 0.0.8
117126

118127
- Fixed compilation error in Client class
119-
- Shorter description for package
128+
- Shorter description for package

README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Appwrite Flutter SDK
22

3-
[![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square.svg)](https://pub.dartlang.org/packages/appwrite)
3+
[![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
6+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
67
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
78
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
89

9-
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).**
10+
**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).**
1011

11-
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.
12-
Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
13-
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
12+
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. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1413

1514

1615

@@ -22,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:
2221

2322
```yml
2423
dependencies:
25-
appwrite: ^0.6.4
24+
appwrite: ^0.7.0
2625
```
2726
2827
You can install packages from the command line:
@@ -37,27 +36,14 @@ pub get appwrite
3736
### Add your Flutter Platform
3837
To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button.
3938

40-
From the options, choose to add a new **Flutter** platform and add your app credentials. Appwrite Flutter SDK currently supports building apps for both iOS and Android.
39+
From the options, choose to add a new **Flutter** platform and add your app credentials. Appwrite Flutter SDK currently supports building apps for Android, iOS, Linux, Mac OS, Web and Windows.
4140

4241
If you are building your Flutter application for multiple devices, you have to follow this process for each different device.
4342

44-
#### iOS
45-
For **iOS** add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode.
46-
47-
#### Android
48-
For **Android** add your app <u>name</u> and <u>package name</u>, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API.
49-
50-
### iOS
51-
52-
The Appwrite SDK uses ASWebAuthenticationSession on iOS 12+ and SFAuthenticationSession on iOS 11 to allow OAuth authentication. You have to change your iOS Deployment Target in Xcode to be iOS >= 11 to be able to build your app on an emulator or a real device.
53-
54-
1. In Xcode, open Runner.xcworkspace in your app's ios folder.
55-
2. To view your app's settings, select the Runner project in the Xcode project navigator. Then, in the main view sidebar, select the Runner target.
56-
3. Select the General tab.
57-
4. In Deployment Info, 'Target' select iOS 11.0
58-
5943
### Android
60-
In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console.
44+
For **Android** first add your app <u>name</u> and <u>package name</u>, Your package name is generally the **applicationId** in your app-level <a href="https://github.com/appwrite/playground-for-flutter/blob/0fdbdff98384fff940ed0b1e08cf14cfe3a2be3e/android/app/build.gradle#L41" target="_blank" rel="noopener">build.gradle</a> file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API.
45+
46+
In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to replace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in the console.
6147

6248
```xml
6349
<manifest>
@@ -74,15 +60,34 @@ In order to capture the Appwrite OAuth callback url, the following activity need
7460
</manifest>
7561
```
7662

63+
### iOS
64+
For **iOS** first add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode.
65+
66+
The Appwrite SDK uses ASWebAuthenticationSession on iOS 12+ and SFAuthenticationSession on iOS 11 to allow OAuth authentication. You have to change your iOS Deployment Target in Xcode to be iOS >= 11 to be able to build your app on an emulator or a real device.
67+
68+
1. In Xcode, open Runner.xcworkspace in your app's ios folder.
69+
2. To view your app's settings, select the Runner project in the Xcode project navigator. Then, in the main view sidebar, select the Runner target.
70+
3. Select the General tab.
71+
4. In Deployment Info, 'Target' select iOS 11.0
72+
73+
### Linux
74+
For **Linux** add your app <u>name</u> and <u>package name</u>, Your package name is generally the **name** in your <a href="https://github.com/appwrite/playground-for-flutter/blob/0fdbdff98384fff940ed0b1e08cf14cfe3a2be3e/pubspec.yaml#L1" target="_blank" rel="noopener">pubspec.yaml<a> file. If you cannot find the correct package name, run the application in linux, and make any request with proper exception handling, you should get the application ID needed to add in the received error message.
75+
76+
### Mac OS
77+
For **Mac OS** add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode.
78+
7779
### Web
7880
Appwrite 0.7, and the Appwrite Flutter SDK 0.3.0 have added support for Flutter Web. To build web apps that integrate with Appwrite successfully, all you have to do is add a web platform on your Appwrite project's dashboard and list the domain your website will use to allow communication to the Appwrite API.
7981

8082
#### Flutter Web Cross-Domain Communication & Cookies
8183
While running Flutter Web, make sure your Appwrite server and your Flutter client are using the same top-level domain and the same protocol (HTTP or HTTPS) to communicate. When trying to communicate between different domains or protocols, you may receive HTTP status error 401 because some modern browsers block cross-site or insecure cookies for enhanced privacy. In production, Appwrite allows you set multiple [custom-domains](https://appwrite.io/docs/custom-domains) for each project.
8284

85+
### Windows
86+
For **Windows** add your app <u>name</u> and <u>package name</u>, Your package name is generally the **name** in your <a href="https://github.com/appwrite/playground-for-flutter/blob/0fdbdff98384fff940ed0b1e08cf14cfe3a2be3e/pubspec.yaml#L1" target="_blank" rel="noopener">pubspec.yaml</a> file. If you cannot find the correct package name, run the application in windows, and make any request with proper exception handling, you should get the application id needed to add in the received error message.
87+
8388
### Init your SDK
8489

85-
<p>Initialize your SDK code with your project ID, which can be found in your project settings page.
90+
<p>Initialize your SDK with your Appwrite server API endpoint and project ID, which can be found in your project settings page.
8691

8792
```dart
8893
import 'package:appwrite/appwrite.dart';
@@ -102,7 +107,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos
102107

103108
### Make Your First Request
104109

105-
<p>Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
110+
<p>Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
106111

107112
```dart
108113
// Register User
@@ -156,12 +161,13 @@ try {
156161
```
157162

158163
### Learn more
159-
You can use followng resources to learn more and get help
164+
You can use following resources to learn more and get help
160165
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-flutter)
161166
- 📜 [Appwrite Docs](https://appwrite.io/docs)
162167
- 💬 [Discord Community](https://appwrite.io/discord)
163168
- 🚂 [Appwrite Flutter Playground](https://github.com/appwrite/playground-for-flutter)
164169

170+
165171
## Contribution
166172

167173
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.

docs/examples/account/get-session.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
void main() { // Init SDK
4+
Client client = Client();
5+
Account account = Account(client);
6+
7+
client
8+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9+
.setProject('5df5acd0d48c2') // Your project ID
10+
;
11+
Future result = account.getSession(
12+
sessionId: '[SESSION_ID]',
13+
);
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

lib/client.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class Client {
2626

2727
this.headers = {
2828
'content-type': 'application/json',
29-
'x-sdk-version': 'appwrite:flutter:0.6.4',
30-
'X-Appwrite-Response-Format' : '0.8.0',
29+
'x-sdk-version': 'appwrite:flutter:0.7.0',
30+
'X-Appwrite-Response-Format' : '0.9.0',
3131
};
3232

3333
this.config = {};
@@ -115,7 +115,7 @@ class Client {
115115
final macinfo = await deviceInfoPlugin.macOsInfo;
116116
device = '(Macintosh; ${macinfo.model})';
117117
}
118-
addHeader('user-agent', '${packageInfo.appName}/${packageInfo.version} $device');
118+
addHeader('user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
119119
} else {
120120
// if web set withCredentials true to make cookies work
121121
_prefs = await SharedPreferences.getInstance();
@@ -141,7 +141,9 @@ class Client {
141141
await this.init();
142142
}
143143

144-
params.removeWhere((key,value) => value == null);
144+
if(params.isNotEmpty) {
145+
params.removeWhere((key,value) => value == null);
146+
}
145147

146148
// Origin is hardcoded for testing
147149
Options options = Options(

lib/enums.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,3 @@ extension HttpMethodString on HttpMethod {
77
return this.toString().split('.').last.toUpperCase();
88
}
99
}
10-
11-
enum OrderType { asc, desc }
12-
13-
extension OrderTypeString on OrderType {
14-
String name() {
15-
return this.toString().split('.').last.toUpperCase();
16-
}
17-
}

lib/services/account.dart

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class Account extends Service {
9696
/// Use this endpoint to create a JSON Web Token. You can use the resulting JWT
9797
/// to authenticate on behalf of the current user when working with the
9898
/// Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
99-
/// from its creation and will be invalid if the user will logout.
99+
/// from its creation and will be invalid if the user will logout in that time
100+
/// frame.
100101
///
101102
Future<Response> createJWT() {
102103
final String path = '/account/jwt';
@@ -319,9 +320,10 @@ class Account extends Service {
319320
///
320321
/// Use this endpoint to allow a new user to register an anonymous account in
321322
/// your project. This route will also create a new session for the user. To
322-
/// allow the new user to convert an anonymous account to a normal account
323-
/// account, you need to update its [email and
324-
/// password](/docs/client/account#accountUpdateEmail).
323+
/// allow the new user to convert an anonymous account to a normal account, you
324+
/// need to update its [email and
325+
/// password](/docs/client/account#accountUpdateEmail) or create an [OAuth2
326+
/// session](/docs/client/account#accountCreateOAuth2Session).
325327
///
326328
Future<Response> createAnonymousSession() {
327329
final String path = '/account/sessions/anonymous';
@@ -361,8 +363,7 @@ class Account extends Service {
361363
for (var item in value) {
362364
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
363365
}
364-
}
365-
else {
366+
} else if(value != null) {
366367
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
367368
}
368369
});
@@ -395,6 +396,24 @@ class Account extends Service {
395396
});
396397
}
397398

399+
}
400+
401+
/// Get Session By ID
402+
///
403+
/// Use this endpoint to get a logged in user's session using a Session ID.
404+
/// Inputting 'current' will return the current session being used.
405+
///
406+
Future<Response> getSession({required String sessionId}) {
407+
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
408+
409+
final Map<String, dynamic> params = {
410+
};
411+
412+
final Map<String, String> headers = {
413+
'content-type': 'application/json',
414+
};
415+
416+
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
398417
}
399418

400419
/// Delete Account Session

lib/services/database.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class Database extends Service {
1111
/// of the project's documents. [Learn more about different API
1212
/// modes](/docs/admin).
1313
///
14-
Future<Response> listDocuments({required String collectionId, List? filters, int? limit, int? offset, String? orderField, OrderType? orderType, String? orderCast, String? search}) {
14+
Future<Response> listDocuments({required String collectionId, List? filters, int? limit, int? offset, String? orderField, String? orderType, String? orderCast, String? search}) {
1515
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
1616

1717
final Map<String, dynamic> params = {
1818
'filters': filters,
1919
'limit': limit,
2020
'offset': offset,
2121
'orderField': orderField,
22-
'orderType': orderType?.name(),
22+
'orderType': orderType,
2323
'orderCast': orderCast,
2424
'search': search,
2525
};

lib/services/functions.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Functions extends Service {
1111
/// return a list of all of the project's executions. [Learn more about
1212
/// different API modes](/docs/admin).
1313
///
14-
Future<Response> listExecutions({required String functionId, String? search, int? limit, int? offset, OrderType? orderType}) {
14+
Future<Response> listExecutions({required String functionId, String? search, int? limit, int? offset, String? orderType}) {
1515
final String path = '/functions/{functionId}/executions'.replaceAll(RegExp('{functionId}'), functionId);
1616

1717
final Map<String, dynamic> params = {
1818
'search': search,
1919
'limit': limit,
2020
'offset': offset,
21-
'orderType': orderType?.name(),
21+
'orderType': orderType,
2222
};
2323

2424
final Map<String, String> headers = {

lib/services/storage.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class Storage extends Service {
1010
/// your results. On admin mode, this endpoint will return a list of all of the
1111
/// project's files. [Learn more about different API modes](/docs/admin).
1212
///
13-
Future<Response> listFiles({String? search, int? limit, int? offset, OrderType? orderType}) {
13+
Future<Response> listFiles({String? search, int? limit, int? offset, String? orderType}) {
1414
final String path = '/storage/files';
1515

1616
final Map<String, dynamic> params = {
1717
'search': search,
1818
'limit': limit,
1919
'offset': offset,
20-
'orderType': orderType?.name(),
20+
'orderType': orderType,
2121
};
2222

2323
final Map<String, String> headers = {
@@ -132,12 +132,13 @@ class Storage extends Service {
132132
/// and spreadsheets, will return the file icon image. You can also pass query
133133
/// string arguments for cutting and resizing your preview image.
134134
///
135-
Future<Response> getFilePreview({required String fileId, int? width, int? height, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, String? output}) {
135+
Future<Response> getFilePreview({required String fileId, int? width, int? height, String? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, String? output}) {
136136
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
137137

138138
final Map<String, dynamic> params = {
139139
'width': width,
140140
'height': height,
141+
'gravity': gravity,
141142
'quality': quality,
142143
'borderWidth': borderWidth,
143144
'borderColor': borderColor,

0 commit comments

Comments
 (0)