Skip to main content

dart_appwrite 31.3.0 copy "dart_appwrite: ^31.3.0" to clipboard
dart_appwrite: ^31.3.0 copied to clipboard

Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API

example/README.md

Examples #

Initialize the client:

import 'package:dart_appwrite/dart_appwrite.dart';
import 'package:dart_appwrite/models.dart' as models;

Client client = Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<YOUR_PROJECT_ID>')
    .setKey('<YOUR_API_KEY>');

Create a user:

Users users = Users(client);

models.User user = await users.create(
  userId: ID.unique(),
  email: 'email@example.com',
  password: 'password',
  name: "Walter O'Brien",
);

Create a row:

TablesDB tablesDB = TablesDB(client);

models.Row row = await tablesDB.createRow(
  databaseId: '<DATABASE_ID>',
  tableId: '<TABLE_ID>',
  rowId: ID.unique(),
  data: {
    'title': 'Hello, world',
    'published': true,
  },
  permissions: [
    Permission.read(Role.any()),
  ],
);

List rows:

models.RowList rows = await tablesDB.listRows(
  databaseId: '<DATABASE_ID>',
  tableId: '<TABLE_ID>',
  queries: [
    Query.equal('published', true),
    Query.orderDesc('\$createdAt'),
    Query.limit(10),
  ],
);

Upload a file:

Storage storage = Storage(client);

models.File file = await storage.createFile(
  bucketId: '<BUCKET_ID>',
  fileId: ID.unique(),
  file: InputFile.fromPath(path: './path-to-file/image.jpg'),
  permissions: [
    Permission.read(Role.any()),
  ],
);

Handle errors:

try {
  models.User user = await users.get(userId: '<USER_ID>');
} on AppwriteException catch (e) {
  print('${e.code} ${e.type}: ${e.message}');
}

All examples and API features are available in the official Appwrite docs.

104
likes
0
points
21k
downloads

Documentation

Documentation

Publisher

verified publisherappwrite.io

Weekly Downloads

Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http

More

Packages that depend on dart_appwrite