Skip to content

πŸ› Bug Report: '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>' with permissions in a documentΒ #162

Description

@ande4485

πŸ‘Ÿ Reproduction steps

  1. create a document in a collection with permissions
adPanelUserDatabase.createDocument(
       databaseId: databaseId,
       collectionId: collectionAdPanelUser,
       documentId: appUser.idDatabase!,
       data: appUser.toJson(),
       permissions: [
         Permission.write(Role.user(appUser.idDatabase!)),
         Permission.update(Role.user(appUser.idDatabase!)),
         Permission.read(Role.users()),
         Permission.delete(Role.user(appUser.idDatabase!))
       ]);
  1. After make an getDocument:
 await adPanelUserDatabase.getDocument(
          databaseId: databaseId,
          collectionId: collectionAdPanelUser,
          documentId: idUser);

πŸ‘ Expected behavior

No error throws

πŸ‘Ž Actual Behavior

I got '_Map<String, dynamic>' is not a subtype of type 'List' , because in this line :

factory Document.fromMap(Map<String, dynamic> map) {
    return Document(
      $id: map['\$id'].toString(),
      $collectionId: map['\$collectionId'].toString(),
      $databaseId: map['\$databaseId'].toString(),
      $createdAt: map['\$createdAt'].toString(),
      $updatedAt: map['\$updatedAt'].toString(),
      $permissions: map['\$permissions'],
      data: map,
    );
  }

Line 41 in document.dart
$permissions are a List but map['$permissions'] are a map.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Linux

🧱 Your Environment

Flutter appwrite 9.0.1.
Flutter 3.10.6
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?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions