Code Monkey home page Code Monkey logo

sdk-for-dart's Introduction

Appwrite Dart SDK

pub package License Version Build Status Twitter Account Discord

This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check previous releases.

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

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 Dart 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

Appwrite

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  dart_appwrite: ^11.0.2

You can install packages from the command line:

dart pub add dart_appwrite

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:

import 'package:dart_appwrite/dart_appwrite.dart';

void main() async {
  Client client = Client()
    .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible
    .setProject('5ff3379a01d25') // Your project ID
    .setKey('cd868c7af8bdc893b4...93b7535db89')
    .setSelfSigned(); // Use only on dev mode with a self-signed SSL cert

  Users users = Users(client);

  try {
    final user = await users.create(userId: ID.unique(), email: "[email protected]", phone: "+123456789", password: "password", name: "Walter O'Brien");
    print(user.toMap());
  } on AppwriteException catch(e) {
    print(e.message);
  }
}

Error handling

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.

Users users = Users(client);

try {
  final user = await users.create(userId: ID.unique(), email: "[email protected]", phone: "+123456789", password: "password", name: "Walter O'Brien");
  print(user.toMap());
} on AppwriteException catch(e) {
  //show message to user or do other operation based on error as required
  print(e.message);
}

Learn more

You can use the following resources to learn more and get help

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

sdk-for-dart's People

Contributors

abnegate avatar christyjacob4 avatar drph4nt0m avatar eldadfux avatar lohanidamodar avatar meldiron avatar stnguyen90 avatar torstendittmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-for-dart's Issues

Upgrade our issue templates to use GitHub issue forms ✍️

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them 🀯.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? πŸ€” Let us know, and we will assign it to you 😊

Happy Appwriting!

πŸ› Bug Report: Using Query causes server error

πŸ‘Ÿ Reproduction steps

Running below code causes AppwriteException: general_unknown, Server Error (500)

  final myCollection = await databases.listDocuments(
    databaseId: dbId,
    collectionId: collectionId,
    queries: [Query.limit(50)],
  );

But, if I passΒ queries: ["limit(100)"]Β it works as expected.

Is this something caused by the new JSON Query structure?

πŸ‘ Expected behavior

  • List of documents should be returned.

πŸ‘Ž Actual Behavior

AppwriteException: general_unknown, Server Error (500)

🎲 Appwrite version

Version [1.4.13]

πŸ’» Operating system

Something else

🧱 Your Environment

Appwrite Cloud

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

storage.createFile not working

πŸ‘Ÿ Reproduction steps

I am trying to upload a file using the code from the example and I get an error.
I tried uploading a text file and a picture (commented out in the code)
Maybe I'm doing something wrong?

my code:

void main(List<String> arguments) async {
  Client client = Client()
    ..setEndpoint(endpoint)
    ..setProject(projectId)
    ..setKey(secretKey)
    ..setSelfSigned();
  Storage storage = Storage(client);

  final content = 'some text file\nmultiline file';
  final file = MultipartFile.fromString('field', content, filename: 'test_text_file.txt', );

  // final file = await MultipartFile.fromPath(
  //   'image.jpg',
  //   './path-to-file/image.jpg',
  //   filename: 'image.jpg',
  //   contentType: MediaType.parse('image/jpeg'),
  // );

  storage.createFile(file: file).then((response) {
    print(response); // File uploaded!
  }).catchError((error) {
    print(error.toString());
    print(error.response);
  });
}
name: appwrite_test
description: A simple command-line application.
version: 1.0.0

environment:
  sdk: '>=2.14.4 <3.0.0'

dependencies:
  dart_appwrite: ^1.0.2

dev_dependencies:
  lints: ^1.0.1

πŸ‘ Expected behavior

the file should be uploaded to the server

πŸ‘Ž Actual Behavior

I see in console:

AppwriteException: No file sent (400)
{message: No file sent, code: 400, version: 0.11.0}

🎲 Appwrite version

Version 0.10.x

πŸ’» Operating system

MacOS

🧱 Your Environment

Dart SDK version: 2.14.4 (stable) (Wed Oct 13 11:11:32 2021 +0200) on "macos_x64"

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Connection refused error on a Flutter project

Thank you for this amazing project it is going to be huge.

I tried to use the dart library on a Flutter project , the dashboard is working fine

but it is not working on flutter side:

here is the code

import 'package:appwrite/appwrite.dart';

void main() {

  final Client client = Client();

  client.setEndpoint('https://localhost:90/v1').setProject('5e9351e30e481').setSelfSigned();

  final Account account = Account(client);

  account.create(email: '[email protected]', password: 'password', name: 'My Name');

}

and this is the error:


E/flutter ( 7039): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: DioError [DioErrorType.DEFAULT]: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 45008
E/flutter ( 7039): #0      DioMixin._request._errorInterceptorWrapper.<anonymous closure> 
package:dio/src/dio.dart:869
E/flutter ( 7039): <asynchronous suspension>
E/flutter ( 7039): #1      DioMixin._request._errorInterceptorWrapper.<anonymous closure> (package:dio/src/dio.dart)
E/flutter ( 7039): #3      _CustomZone.runUnary  (dart:async/zone.dart:1085:19)
E/flutter ( 7039): #4      _FutureListener.handleError  (dart:async/future_impl.dart:159:20)
E/flutter ( 7039): #5      Future._propagateToListeners.handleError  (dart:async/future_impl.dart:694:47)
E/flutter ( 7039): #6      Future._propagateToListeners  (dart:async/future_impl.dart:715:24)
E/flutter ( 7039): #7      Future._completeError  (dart:async/future_impl.dart:534:5)
E/flutter ( 7039): #8      _SyncCompleter._completeError  (dart:async/future_impl.dart:58:12)
E/flutter ( 7039): #9      _Completer.completeError  (dart:async/future_impl.dart:30:5)
E/flutter ( 7039): #10     Future.any.<anonymous closure>  (dart:async/future.dart:464:45)
E/flutter ( 7039): #11     _rootRunBinary  (dart:async/zone.dart:1204:38)
E/flutter ( 7039): #12     _CustomZone.runBinary  (dart:async/zone.dart:1093:19)
E/flutter ( 7039): #13     _FutureListener.handleError  (dart:async/future_impl.dart:155:20)
E/flutter ( 7039): #14     Future._propagateToListeners.handleError  (dart:async/future_impl.dart:694:47)
E/flutter ( 7039): #15     Future._propagateToListeners  (dart:async/future_impl.dart:715:24)
E/flutter ( 7039): #16     Future._completeError  (dart:async/future_impl.dart:534:5)
E/flutter ( 7039): #17     _AsyncAwaitCompleter.completeError  (dart:async-patch/async_patch.dart:43:15)
E/flutter ( 7039): #18     DioMixin._dispatchRequest (package:dio/src/dio.dart)
E/flutter ( 7039): <asynchronous suspension>
E/flutter ( 7039): #19     DioMixin._request._interceptorWrapper.<anonymous closure>.<anonymous closure>.<anonymous closure> 
package:dio/src/dio.dart:849
E/flutter ( 7039): #20     DioMixin.checkIfNeedEnqueue 
package:dio/src/dio.dart:1117
E/flutter ( 7039): #21     DioMixin._request._interceptorWrapper.<anonymous closure>.<anonymous closure> 
package:dio/src/dio.dart:846
E/flutter ( 7039): #22     new Future.<anonymous closure>  (dart:async/future.dart:176:37)
E/flutter ( 7039): #23     _rootRun  (dart:async/zone.dart:1180:38)
E/flutter ( 7039): #24     _CustomZone.run  (dart:async/zone.dart:1077:19)
E/flutter ( 7039): #25     _CustomZone.runGuarded  (dart:async/zone.dart:979:7)
E/flutter ( 7039): #26     _CustomZone.bindCallbackGuarded.<anonymous closure>  (dart:async/zone.dart:1019:23)
E/flutter ( 7039): #27     _rootRun  (dart:async/zone.dart:1184:13)
E/flutter ( 7039): #28     _CustomZone.run  (dart:async/zone.dart:1077:19)
E/flutter ( 7039): #29     _CustomZone.bindCallback.<anonymous closure>  (dart:async/zone.dart:1003:23)
E/flutter ( 7039): #30     Timer._createTimer.<anonymous closure>  (dart:async-patch/timer_patch.dart:23:15)
E/flutter ( 7039): #31     _Timer._runTimers  (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter ( 7039): #32     _Timer._handleMessage  (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter ( 7039): #33     _RawReceivePortImpl._handleMessage  (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter ( 7039):


I also generate an Api key and used it but it does not work and prints the same error:

import 'package:appwrite/appwrite.dart';

void main() {
  final Client client = Client();

  client.setEndpoint('https://localhost:90/v1')
  .setProject('5e9351e30e481')
  .setKey('c7f7afea3c336ad75b9a2dcf0a91a91c5808cebe601127d154257f0e8d0836b442070dbc9d74c581a828bd1436f738fcd8239f7d5f3c1e3f583227588363cabddb7c9c12d74f1d8187fe533068197cfe631c0d8af4309668a231b208c8a82df9c38c921a8ae3fa93aa42892eb786cc39408dce965f4ade3da26fff21527c5d49')
  .setSelfSigned();

  final Account account = Account(client);

  account.create(email: '[email protected]', password: 'password', name: 'My Name');

}

πŸ› Bug Report: Updating Attributes with Null Default Fails

πŸ‘Ÿ Reproduction steps

When I update an attribute using Databases.update#Attribute and pass in null for xdefault,

πŸ‘ Expected behavior

It should set the default value of that attribute to null.

πŸ‘Ž Actual Behavior

It actually throws an exception: AppwriteException: general_argument_invalid, Param "default" is not optional. (400)

I've found that modifying https://github.com/appwrite/sdk-for-dart/blob/master/lib/src/client_mixin.dart#L15 to params.removeWhere((key, value) => value == null && key != 'default'); locally fixes the issue. Looks like the default: null header is being removed before sending the http request, which is causing the exception. This does not seem like a good fix for the issue, but it narrows down where the issue is coming from.

🎲 Appwrite version

Version 0.10.x

πŸ’» Operating system

MacOS

🧱 Your Environment

Using this in a CLI script to automatically update my attributes.

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

ican get collection from web console, but i get it from appwrite_dart trow '404' not found

πŸ‘Ÿ Reproduction steps

i upgrade appwrite server to v:0.11.0.170 and edit my flutter app code.
then i test apps again.but app content isnt showed.
then i check code, i found appwrite error
then check collection id and collection in web console .. there are fine.

then i user dart_Appwrite package to list documents it returns
http://127.0.0.1:9100?uri=http://127.0.0.1:4901/b6H65rThbgs=/ [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: AppwriteException: Collection not found (404) #0 ClientIO.call (package:dart_appwrite/src/client_io.dart:117:9) <asynchronous suspension> #1 Test1.<anonymous closure> (package:testwin/test/1.dart:16:20) <asynchronous suspension>

i tride APpwrite pkg too
it return Reloaded 34 of 1939 libraries in 3,010ms. [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: AppwriteException: Collection not found (404) #0 ClientMixin.prepareResponse (package:appwrite/src/client_mixin.dart:76:9) #1 ClientIO.call (package:appwrite/src/client_io.dart:242:19) <asynchronous suspension> #2 Database.listDocuments (package:appwrite/services/database.dart:39:17) <asynchronous suspension> #3 Test1.<anonymous closure> (package:testwin/test/1.dart:16:20) <asynchronous suspension>
then i try another functions...all are reruns null

πŸ‘ Expected behavior

i canged my server domain,openssl key

πŸ‘Ž Actual Behavior

i dont know

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Something else

🧱 Your Environment

windows 10
flutter 2.5.3
appwrite v:0.11.0.170
flutter pkg
dart_appwrite: ^1.0.2
appwrite: ^2.0.3

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: Version 8.0.1 required dart 2.19 which not available as functions runtime.

πŸ‘Ÿ Reproduction steps

When publishing any function to Appwrite using the latest 8.0.1 version you get an error like this

Because every version of appwrite_function from path depends on dart_appwrite ^8.0.1 which depends on http >=0.13.6 <1.0.1, every version of appwrite_function from path requires http >=0.13.6 <1.0.1.
So, because http >=0.13.6 requires SDK version >=2.19.0 <3.0.0 or ^3.0.0 and open_runtimes_dart depends on appwrite_function from path, version solving failed.

Version 0.13.6 of http supports only dart 2.19 and up.

Currently, OpenRuntime doesn't support dart 2.19 so I couldn't deploy a dart function.

I've checked that issue after seeing this in Discord.

πŸ‘ Expected behavior

Maybe downgrading the version to 0.13.5 to have support for all available dart open-runtime.

πŸ‘Ž Actual Behavior

The above error.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Linux

🧱 Your Environment

1.3.6

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: Functions(client).list return false instead of empty dictionary as response when no variables are set

πŸ‘Ÿ Reproduction steps

When a function has no set variables it is displayed correctly in web panel as
image
but what is returned by Functions(client).list is:
image
thus producing an exception in mapping:
image

πŸ‘ Expected behavior

Empty vars should return empty dictionary, method works correctly

πŸ‘Ž Actual Behavior

empty vars return false, method throws an exception

🎲 Appwrite version

Version 0.15.x

πŸ’» Operating system

Linux

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Timeouts on Async Cloud Function Execution

Users (S3ppo and MikeAmir) have reported timeouts from simple dart cloud functions:

S3ppo:

void main(List<String> args) async {
  // Initialise the client SDK
  Map<String, String> envVars = Platform.environment;
  final Client client = Client();
  client
      .setEndpoint(envVars['APPWRITE_ENDPOINT'])
      .setProject(envVars['APPWRITE_PROJECT_ID'])
      .setKey(envVars['APPWRITE_API_KEY']);
  Users users = Users(client);
  Teams teams = Teams(client);

  final payload = jsonDecode(envVars['APPWRITE_FUNCTION_DATA']);
  final userId = payload['userId'];
  final teamId = payload['teamId'];

  //TODO: make checks if the user is allowed

  await addTeamMember(userId, teamId, teams, users);
  print('User: $userId added to team: $teamId');
}

Future<UsersApi> getUser(String userid, Users users) async {
  try {
    Response result = await users.get(userId: userid);
    return UsersApi.fromJson(result.data);
  } on AppwriteException catch (error) {
    print(error);
    throw error;
  }
}

Future<dynamic> addTeamMember(String userId, String teamId, Teams teams, Users users) async {
  UsersApi user = await getUser(userId, users);
  try {
    Response result = await teams.createMembership(
        teamId: teamId, email: user.email, roles: ['member'], url: '');
    return result;
  } on AppwriteException catch (error) {
    print(error);
    throw error;
  }
}

MikeAmir:

import 'dart:io';
import 'package:dart_appwrite/dart_appwrite.dart';
import 'dart:math';

void main() {
  try {
    final Map<String, dynamic> env = Platform.environment;
    final Client client = Client(endPoint: env['APPWRITE_ENDPOINT'], selfSigned: true);
    client.setProject(env['APPWRITE_PROJECT']);
    client.setKey(env['API_KEY']);
    final Database database = Database(client);
    final Random random = Random();
    final int randInt = random.nextInt(1000);
    database.createDocument(
      collectionId: '6139cb91b2d89',
      write: ['*'],
      read: ['*'],
      data: {
        'title': 'Google Pixel 6 $randInt',
        'description': 'Latest phone by Google',
        'price': 500,
        'images': ['http://localhost/v1/storage/files/613bf62094c82/view?project=6139cb70bdcd9&mode=admin']
      },
    );
  } catch (e) {
    print(e);
  }
  return;
}

I tested using S3ppo's code and it ran fine, but it was because I was using version 0.6.1 of the SDK. After switching to version 1.0.1 of the SDK, it took 3x longer to exit. For both versions, the print('User: $userId added to team: $teamId'); executes decently quick, but it takes several seconds longer before the program exits. If we add an exit(0) after the print(), the program exits timely.

According to this, dart waits for all async functions to execute before exiting. This leads me to theorize there is some async function executing that is preventing the program from exiting.

πŸ“š Documentation: Client.call supports ResponseType.bytes but how to respond from server?

πŸ’­ Description

The sdk supports calls like final respo = await client.call(HttpMethod.get, path: "myPath", responseType: ResponseType.bytes); but I can't figure out how a dart cloud function can respond accordingly. This is not tackled in the docs. Furthermore how can we send requests with byte data payloads?

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Unhandled Exception: PlatformException(CANCELED, User canceled login, null)

We receive PlatformException if we cancel the authentication process.

Platform

  • Android

Step to reproduce

  1. Tap one of the auth button
  2. when the system shows the app chooser dialog close it
  3. note that the exception is thrown

Exception:

E/flutter ( 4056): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(CANCELED, User canceled login, null)
E/flutter ( 4056): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 4056): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter ( 4056): <asynchronous suspension>
E/flutter ( 4056): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter ( 4056): #3      FlutterWebAuth.authenticate (package:flutter_web_auth/flutter_web_auth.dart:35:27)
E/flutter ( 4056): #4      Account.createOAuth2Session (package:appwrite/services/account.dart:325:31)
E/flutter ( 4056): #5      PlaygroundState.build.<anonymous closure> (package:ftest/main.dart:86:24)
E/flutter ( 4056): #6      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:930:19)
E/flutter ( 4056): #7      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1017:38)
E/flutter ( 4056): #8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 4056): #9      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:522:11)
E/flutter ( 4056): #10     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter ( 4056): #11     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter ( 4056): #12     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter ( 4056): #13     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter ( 4056): #14     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter ( 4056): #15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter ( 4056): #16     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter ( 4056): #17     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter ( 4056): #18     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 4056): #19     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 4056): #20     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 4056): #21     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 4056): #22     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 4056): #23     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 4056): #24     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 4056): #25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 4056): #26     _invoke1 (dart:ui/hooks.dart:281:10)
E/flutter ( 4056): #27     _dispatchPointerDataPacket (dart:ui/hooks.dart:190:5)
E/flutter ( 4056): 

πŸ› Bug Report: type '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>'

πŸ‘Ÿ Reproduction steps

While creating collection, some combination of permissions causes server to respond with a wrong type for "permissions" which leads to SDK crash.
https://github.com/appwrite/sdk-for-dart/blob/master/lib/src/models/collection.dart#L12 and https://github.com/appwrite/sdk-for-dart/blob/master/lib/src/models/collection.dart#L44

Wrong response:
{"$id":"category","$createdAt":"2023-06-08T12:45:14.832+00:00","$updatedAt":"2023-06-08T12:45:14.832+00:00","$permissions":{"0":

Screenshot 2023-06-08 at 14 40 54

πŸ‘ Expected behavior

SDK should handle both response types array and object OR server should be consistent with a response structure.

πŸ‘Ž Actual Behavior

SDK handles response only while permissions field is an array.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Linux

🧱 Your Environment

Local selfohosted appwrite 1.3.4

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: dart_appwrite 10.1.0 which depends on http >=0.13.6 <1.0.1

πŸ‘Ÿ Reproduction steps

The current version of dart pub http is 1.1.2 but the package dart_appwrite depends on an older version.

πŸ‘ Expected behavior

dart_appwrite dependency of http should be updated.

πŸ‘Ž Actual Behavior

So the newest compatible version of http is 1.0.0

🎲 Appwrite version

Version 1.4.x

πŸ’» Operating system

Linux

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Update is returning Collection instead of Database

πŸ‘Ÿ Reproduction steps

Database.update();

πŸ‘ Expected behavior

It should return models.Database.fromMap(res.data);

πŸ‘Ž Actual Behavior

But it returns a collection
Screenshot from 2022-07-28 18-27-21

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Linux

🧱 Your Environment

no

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Question: How do I generate user session?

I want to, when a given email and password, authenticate and generate session. I cannot find proper methods for it under Users and Account class. Can someone help me?

πŸ› Bug Report: Cannot set min and max values of numeric attribute to null

πŸ‘Ÿ Reproduction steps

When I attempt to update a numeric attribute (int or float) using Databases.updateIntAttribute() or Databases.updateFloatAttribute():

πŸ‘ Expected behavior

I should be able to set the min and max values to null to let Appwrite choose the default values for me.

πŸ‘Ž Actual Behavior

I actually need to pass in a non-null value.

🎲 Appwrite version

Version 0.10.x

πŸ’» Operating system

Linux

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸš€ Feature: context.res.send(); , 1st parameter accepts only a String .

πŸ”– Feature description

Allow context.res.send(); 1st parameter accepts String and bytes so as to send Uint8List as data.
I am trying to send Uint8List as the 1st parameter getting the below error

Future<dynamic> main(final context) async {
  final pdf = PDF();
  final order = FakeOrder();
  var fakeOrder = order.createFakeOrder();
  context.log(fakeOrder.toJson().toString());
  final Uint8List? bytes = await pdf.createAndSave(fakeOrder);

  if (bytes != null) {
    context.log('PDF created.');
    context.log(bytes);

    return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});
  }

  return context.error("Someting gone wrong");
}
type 'Uint8List' is not a subtype of type 'String' of 'body'
#0      main (package:generate_pdf/main.dart)
<asynchronous suspension>
#1      Future.any.onValue (dart:async/future.dart:615)
<asynchronous suspension>

🎀 Pitch

Allow to accept 1st parameter as dynamic

OLD

context.res.send(<String>, <int>, Map<String,dynamic>);

NEW

context.res.send(<dynamic>, <int>, Map<String,dynamic>);

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: createFloatAttribute() 'toDouble' was called on null.

πŸ‘Ÿ Reproduction steps

Execute the following function:

database.createFloatAttribute(
          collectionId: "collection",
          key: "someKey",
          xrequired: true)

πŸ‘ Expected behavior

The function should be executed without an error.

πŸ‘Ž Actual Behavior

The function returns:

NoSuchMethodError: The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:68:5)
#1      new AttributeFloat.fromMap (package:dart_appwrite/src/models/attribute_float.dart:49:32)
#2      Database.createFloatAttribute (package:dart_appwrite/services/database.dart:279:34)
<asynchronous suspension>

As I can see the method toDouble is called on parameter that is not required. The problem is the min,max or xdefault parameter.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Linux

🧱 Your Environment

V0.12

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: createFloatAttribute() 'AppwriteException: Invalid min: Value must be a valid float (400)'

πŸ‘Ÿ Reproduction steps

  1. Create collection via interface in appwrite console and add an float attribute without min and max
  2. Copy the json
  3. Call AttributeFloat.fromMap(json) (Bug #16 needs to be fixed), but simple workaround is adding xdefault: map['default']?.toDouble() in AttributeFloat.fromMap
  4. call database.createFloatAttribute(collectionId: <the_collection_id>, key: attributeFloat.key, xrequired: attributeFloat.xrequired, min: attributeFloat.min.toString(), max: attributeFloat.max.toString(), xdefault: attributeFloat.xdefault.toString(), array: attributeFloat.array);

πŸ‘ Expected behavior

Creating the correct attribute with min and max values

πŸ‘Ž Actual Behavior

AppwriteException: Invalid min: Value must be a valid float (400)
Attribute doesn't get created correctly

🎲 Appwrite version

Version 0.12.1.201

πŸ’» Operating system

Linux

🧱 Your Environment

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸš€ Feature: Improve Pub Points on pub.dev

πŸ”– Feature description

pub.dev score: https://pub.dev/packages/dart_appwrite/score

  1. Use an OSI-approved license. Sample projects with a valid BSD-3 license
  2. Code has no errors, warnings, lints, or formatting issues

🎀 Pitch

Packages with a higher pub points look better.

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: Getting Started in https://github.com/appwrite/sdk-for-dart contains a lot of bugs

πŸ‘Ÿ Reproduction steps

Open https://github.com/appwrite/sdk-for-dart and scroll to get started section. This code have a lot of bugs and its not valid dart code

import 'package:dart_appwrite/dart_appwrite.dart';

void main() async {
Client client = Client();
.setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible
.setProject('5ff3379a01d25') // Your project ID
.setKey('cd868c7af8bdc893b4...93b7535db89')
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert

Users users = Users(client);

try {
final response = await users.create(userId: '[USER_ID]', email: β€˜[email protected]’,password: β€˜password’, name: β€˜name’);
print(response.data);
} on AppwriteException catch(e) {
print(e.message);
}
}

πŸ‘ Expected behavior

It should work

πŸ‘Ž Actual Behavior

It doesnt work

🎲 Appwrite version

Version 0.10.x

πŸ’» Operating system

MacOS

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

πŸ› Bug Report: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>'

πŸ‘Ÿ Reproduction steps

$permissions: map['$permissions'] modelling does work with appwrite version v:1.0.1.500

πŸ‘ Expected behavior

permission should be Map in Collection model

πŸ‘Ž Actual Behavior

"$permissions" is [_InternalLinkedHashMap] but in model is List

🎲 Appwrite version

Version 0.10.x

πŸ’» Operating system

Linux

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Why are parameters not strongly typed ?

πŸ‘Ÿ Reproduction steps

Not really a bug but I was wondering if there was a specific reason to not add strongly typing to all services parameters ?

Examples for database service :

Future<models.DocumentList> listDocuments(
      {required String collectionId,
      List? filters,
      int? limit,
      int? offset,
      String? orderField,
      String? orderType,
      String? orderCast,
      String? search})

where filters list is not typed, or :

Future<models.Document> createDocument(
      {required String collectionId,
      required Map data,
      List? read,
      List? write,
      String? parentDocument,
      String? parentProperty,
      String? parentPropertyType})

where data, read and write are not typed either.

Same goes for certain responses that simply return a Response or sometimes just an untyped Future.

This makes the SDK really hard to use as we have to always refer to the documentation and hope that stuff we are looking for is defined there.

πŸ‘ Expected behavior

As a developer, I would expect following typing for examples above:

Future<models.DocumentList> listDocuments(
      {required String collectionId,
      List<Filter>? filters,
      int? limit,
      int? offset,
      String? orderField,
      String? orderType,
      String? orderCast,
      String? search})

where filters list is not typed, or :

Future<models.Document> createDocument(
      {required String collectionId,
      required Map<String, dynamic> data,
      List<Rule>? read,
      List<Rule>? write,
      String? parentDocument,
      String? parentProperty,
      String? parentPropertyType})

πŸ‘Ž Actual Behavior

Many methods are not strongly typed as explained in introduction.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

MacOS

🧱 Your Environment

Tested on AppWrite 0.11.0 with following Dart packages:

  • appwrite: ^2.0.3
  • dart_appwrite: ^1.0.2

(similar problems for Dart or Flutter package).

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.