Skip to content
Back

Appwrite Flutter ID.unique() not working

  • 0
  • Self Hosted
  • Flutter
Ewyn
18 Mar, 2025, 10:32

HEy there! i used ID.unique() quite a lot. but suddenly, Flutter doesnt correctly recognize it.

Instead of saving a unique ID, i get te literal ID "unique()"

Why could that be? flutter: Signature ID: unique() Print ID

Future<void> uploadSignature( String name, String fileName, int isCustomer, String documentID) async { try { log('Uploading Signature...'); String signatureID = ID.unique(); print('Signature ID: $signatureID'); final fullPath = await _getFullImagePath(fileName); final file = File(fullPath); if (await file.exists()) { await appwriteDatabaseHelper.database.createDocument( documentId: signatureID, databaseId: appwriteDatabaseID, collectionId: appwriteSignatureCollection, data: { 'signatureID': signatureID, 'name': name, 'isCustomer': isCustomer, 'servicescheincollection': documentID, }, ); log('Uploaded Signature $signatureID successfully'); log('Uploading Signature to storage...'); try { await uploadImage(fullPath, signatureID); } catch (e) { log('Uploading Signature failed: $e'); } } else { log('File not found: $fullPath'); } } catch (e) { log('Uploading Signature failed: $e'); } }

Function

When pressing on the unique Function, it makes sense cause it only says this

``part of appwrite;

/// Helper class to generate ID strings for resources. class ID { ID._();

/// Have Appwrite generate a unique ID for you. static String unique() { return 'unique()'; }

/// Uses [id] as the ID for the resource. static String custom(String id) { return id; } } `` and literally returns unique()...

TL;DR
The developer is encountering an issue with Flutter where ID.unique() is not generating unique IDs but returning 'unique()' instead. The issue could be due to the implementation of the unique() method in the ID class. The method simply returns the string 'unique()' instead of generating a unique ID. To resolve this, the unique() method in the ID class needs to be modified to generate a unique ID string.
Ewyn
18 Mar, 2025, 10:38

I looked into a different branch and its working as intended with the same Version of appwrite. WHat could i have made it not work here?

i´ll gladly provide more code...

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