Closed heralight closed 1 year ago
Hey, thanks for reporting this. Yes your workaround should work fine, its just one source of entropy from many. I got a working solution for web without adding 3rd party dependencies using dart:html but I got into (unrelated) issues that are preventing tests from running. I'll try to publish the new version by the end of the week.
should be fixed now
@geommr This is still not working. Actually the problem is in touching anything relating to Platform in web. See the stack trace below:
Error: Unsupported operation: Platform._localHostname
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_
dart-sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart 254:5 _localHostname
dart-sdk/lib/io/platform_impl.dart 72:18 get localHostname
dart-sdk/lib/io/platform.dart 66:43 get _localHostname
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 872:8 get
dart-sdk/lib/io/platform.dart 129:38 get localHostname
packages/cuid2/src/cuid2_base.dart 93:31 [_createFingerprint]
@srmncnk weird, it works on scaffolded flutter web app and Platform shouldnt even be invoked. can you give me a minimum reproducible example? or more details about the host?
@geommr Sorry, false positive. Works, you can close this.
Hi,
Thank you for your package, very helpful. I tried to include it inside a mobile/web project but I had an incompatibility with the code for the web platform.
The problem
_createFingerprint() inside cuid2_base.dart use Platform.localHostname; and pid.
do you have any recommendation or sample for web integration please ?
Do you think that replace it for web by a Math.random is enough like said that inside: https://github.com/paralleldrive/cuid2/blob/6c64c5d118885eaef9e7594de4416dc4945e3460/src/index.js#L50
a simple fix will in cuid2_base.dart:
and with that the web platform will supported.
Best regards,
Alexandre