I've been working with Flutter and Firebase lately, I'm facing a confusing problem today and would like some help.
I have a Collection in Firebase Cloud Firestore that contains Documents which their names are quite long. The photo below shows them:
I wrote a function in Dart to check the existence of a specific document, it's also pretty simple:
Future<String> checkForExistance(String mnemonic) async {
final String seedHex = bip39.mnemonicToSeedHex(mnemonic);
final snapShot = await FirebaseFirestore.instance
.collection('wallets')
.doc(seedHex)
.get();
if (!snapShot.exists) {
if (kDebugMode) {
print('SnapShot not exist');
}
return 'NO_IDEA';
} else {
if (kDebugMode) {
print('Snapshot Exist');
}
return seedHex;
}
}
The return result is always 'SnapShot not exist'.
The return is always 'SnapShot not exist' even though I've made sure I'm checking for the existence of exactly what I need.
Even when I hard coded the name of one of those documents, the result is 'SnapShot not exist' (this is what confuses me).
Future<String> checkForExistance(String mnemonic) async {
final String seedHex = bip39.mnemonicToSeedHex(mnemonic);
final snapShot = await FirebaseFirestore.instance
.collection('wallets')
.doc(**'hard coded'**)
.get();
if (!snapShot.exists) {
if (kDebugMode) {
print('SnapShot not exist');
}
return 'NO_IDEA';
} else {
if (kDebugMode) {
print('Snapshot Exist');
}
return seedHex;
}
}
So I tried creating a document with a shorter name (the 's' at the end of the image) and hard coded it, the results returned as expected which is 'Snapshot Exist'.
Is it because my documents name is too long that Firebase search is not working as expected?
Thanks for everyone's help.
