My flutter data model uses UniqueKey to generate unique keys for firebase documents:
final String uKey = UniqueKey().toString();
DocumentReference documentReferencer =
_mainCollection.doc(userUid).collection('teams').doc(uKey);
Typically this generates a key e.g. [#81215]
This has been working for a number of years now.
I rebuilt the app with flutter 3.22.1 and now on IOS the same code is generating a single key, literally: Instance of 'UniqueKey'.
This is not occurring on Android where my test device is generating unique keys as before.
I'm using Xcode 15.4 on an iMac running Sonoma 14.5
Pretty much every collection I have in the app uses this method to create a unique key so the option to replace UniqueKey with an alternative is not so simple.
As far as my googling goes I can't see any other reports of this issue. Therefore creating this question to check whether anyone has hit the same problem and hopefully solved it.
UniqueKey().toString(
) return unique strings anyway. As with all hash codes, there is the possibility for a hash collision, especially when the hash code is being truncated to 5 hex digits.collection().add()
, which generates a document reference with a unique ID for you? This is exceptionally common, and is well-documented.