1
0
Fork 0
mirror of synced 2024-07-05 14:40:42 +12:00
appwrite/docs/sdks/dart/EXAMPLES.md

58 lines
1,002 B
Markdown
Raw Normal View History

2020-04-12 18:15:33 +12:00
# Examples
Init your Appwrite client:
```dart
Client client = Client();
client
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
.setProject('5e8cf4f46b5e8') // Your project ID
.setSelfSigned() // Remove in production
;
```
2021-01-07 02:45:47 +13:00
Create a new user:
2020-04-12 18:15:33 +12:00
```dart
2021-01-07 02:45:47 +13:00
Users users = Users(client);
2020-04-12 18:15:33 +12:00
2021-01-07 02:45:47 +13:00
Response result = await users.create(
email: 'email@example.com',
password: 'password',
);
2020-04-12 18:15:33 +12:00
```
Fetch user profile:
```dart
2021-01-07 02:45:47 +13:00
Users users = Users(client);
2020-04-12 18:15:33 +12:00
2021-01-07 02:45:47 +13:00
Response profile = await users.get(
userId: '[USER_ID]',
);
2020-04-12 18:15:33 +12:00
```
Upload File:
```dart
Storage storage = Storage(client);
MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg');
storage.createFile(
file: file,
read: ['*'],
write: []
)
.then((response) {
print(response); // File uploaded!
})
.catchError((error) {
print(error.response);
});
```
All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs)