appwrite/docs/sdks/dart/GETTING_STARTED.md

39 lines
1.3 KiB
Markdown
Raw Normal View History

2021-03-08 11:19:18 +00:00
## Getting Started
### Initialize & Make API Request
Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example:
```dart
Client client = Client()
.setProject('<YOUR_PROJECT_ID>')
.setKey('<YOUR_API_KEY>');
2021-03-08 11:19:18 +00:00
Users users = Users(client);
2021-03-10 01:36:25 +00:00
User user = await users.create(
userId: ID.unique(),
email: 'email@example.com',
phone: '+123456789',
password: 'password',
name: 'Walter O'Brien'
);
2021-03-11 04:53:40 +00:00
```
2021-03-26 07:16:14 +00:00
### Error handling
2021-03-26 07:47:06 +00:00
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.
2021-03-26 07:16:14 +00:00
```dart
try {
User user = await users.create(...);
2021-03-26 07:16:14 +00:00
} on AppwriteException catch(e) {
// Handle the error
2021-03-26 07:16:14 +00:00
}
```
2021-03-11 04:53:40 +00:00
### Learn more
2021-07-07 10:25:49 +00:00
You can use the following resources to learn more and get help
2021-03-15 03:23:24 +00:00
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
2021-03-14 04:29:55 +00:00
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)
2021-03-15 03:23:24 +00:00
- 🚂 [Appwrite Dart Playground](https://github.com/appwrite/playground-for-dart)