Skip to content
Back

sequence on model has wrong type

  • 0
  • Flutter
  • Cloud
FatihSalikutluk
28 Jul, 2025, 19:50

When I create a document everything works fine. But when I load a model, then I get the following error: "type String is not a sub type of int" which totaly make sense. But in the lib the code is like the following:

/// Document automatically incrementing ID. final int $sequence;

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

and is receives map['sequence'], as "1" for example. So it is a String and is cannot converted to an in on the fromMap method.

TL;DR
The developer is encountering an error because the code is trying to store a sequence as an integer when it is being provided as a string. The solution is to update the data type of $sequence in the Document class to String instead of int.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more