Skip to content

Commit d8303f7

Browse files
committed
Upgraded to support Appwrite 0.8
1 parent e5d0f3a commit d8303f7

36 files changed

+819
-33
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.6.0
2+
3+
- Upgraded to Null-safety, minimum Dart SDK required 2.12.0
4+
- Upgraded all underlying dependencies to null safe version
5+
- BREAKING Renamed users.deleteUser to users.delete
6+
- BREAKING Renamed parameter inviteId to membershipId on teams.updateMembershipStatus, teams.deleteMembership
7+
- JWT Support client.setJWT('JWT_GENERATED_IN_CLIENT')
8+
- [Update membership roles](https://appwrite.io/docs/client/teams?sdk=dart#teamsUpdateMembershipRoles)
9+
- New awesome image preview features, supports borderRadius, borderColor, borderWidth
10+
111
## 0.5.0-dev.1
212

313
- Upgraded to Null-safety, minimum Dart SDK required 2.12.0

README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
[![pub package](https://img.shields.io/pub/v/dart_appwrite.svg?style=flat-square)](https://pub.dartlang.org/packages/dart_appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-0.7.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 0.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).**
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-dart/releases).**
1010

1111
> This is the Dart SDK for integrating with Appwrite from your Dart server-side code. If you're looking for the Flutter SDK you should check [appwrite/sdk-for-flutter](https://github.com/appwrite/sdk-for-flutter)
1212
@@ -24,7 +24,7 @@ Add this to your package's `pubspec.yaml` file:
2424

2525
```yml
2626
dependencies:
27-
dart_appwrite: ^0.5.0-dev.1
27+
dart_appwrite: ^0.6.0
2828
```
2929
3030
You can install packages from the command line:
@@ -47,6 +47,7 @@ void main() async {
4747
.setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible
4848
.setProject('5ff3379a01d25') // Your project ID
4949
.setKey('cd868c7af8bdc893b4...93b7535db89')
50+
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
5051
5152
Users users = Users(client);
5253
@@ -59,6 +60,21 @@ void main() async {
5960
}
6061
```
6162

63+
### Error handling
64+
The Appwrite Dart SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
65+
66+
```dart
67+
Users users = Users(client);
68+
69+
try {
70+
final response = await users.create(email: ‘[email protected]’,password: ‘password’, name: ‘name’);
71+
print(response.data);
72+
} on AppwriteException catch(e) {
73+
//show message to user or do other operation based on error as required
74+
print(e.message);
75+
}
76+
```
77+
6278
### Learn more
6379
You can use followng resources to learn more and get help
6480
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.createRecovery(
14+
15+
url: 'https://example.com',
16+
);
17+
18+
result
19+
.then((response) {
20+
print(response);
21+
}).catchError((error) {
22+
print(error.response);
23+
});
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.createVerification(
14+
url: 'https://example.com',
15+
);
16+
17+
result
18+
.then((response) {
19+
print(response);
20+
}).catchError((error) {
21+
print(error.response);
22+
});
23+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.deleteSession(
14+
sessionId: '[SESSION_ID]',
15+
);
16+
17+
result
18+
.then((response) {
19+
print(response);
20+
}).catchError((error) {
21+
print(error.response);
22+
});
23+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.deleteSessions();
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

docs/examples/account/delete.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.delete();
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

docs/examples/account/get-logs.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.getLogs();
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

docs/examples/account/get-prefs.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.getPrefs();
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

docs/examples/account/get-sessions.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.getSessions();
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

docs/examples/account/get.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.get();
14+
15+
result
16+
.then((response) {
17+
print(response);
18+
}).catchError((error) {
19+
print(error.response);
20+
});
21+
}

docs/examples/account/update-email.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.updateEmail(
14+
15+
password: 'password',
16+
);
17+
18+
result
19+
.then((response) {
20+
print(response);
21+
}).catchError((error) {
22+
print(error.response);
23+
});
24+
}

docs/examples/account/update-name.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.updateName(
14+
name: '[NAME]',
15+
);
16+
17+
result
18+
.then((response) {
19+
print(response);
20+
}).catchError((error) {
21+
print(error.response);
22+
});
23+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.updatePassword(
14+
password: 'password',
15+
);
16+
17+
result
18+
.then((response) {
19+
print(response);
20+
}).catchError((error) {
21+
print(error.response);
22+
});
23+
}

docs/examples/account/update-prefs.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:dart_appwrite/dart_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+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.updatePrefs(
14+
prefs: {},
15+
);
16+
17+
result
18+
.then((response) {
19+
print(response);
20+
}).catchError((error) {
21+
print(error.response);
22+
});
23+
}

0 commit comments

Comments
 (0)