Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not support web #3

Open
hcanyz opened this issue Aug 3, 2023 · 3 comments · May be fixed by #4
Open

not support web #3

hcanyz opened this issue Aug 3, 2023 · 3 comments · May be fixed by #4

Comments

@hcanyz
Copy link

hcanyz commented Aug 3, 2023

I tried to compile the web platform, but got the following error.

/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/fnv-1.0.1/lib/src/fnv_constants.dart:3:26: Error: The integer literal 0xcbf29ce484222325 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript. In JavaScript 0xcbf29ce484222000 is the nearest value that can be represented exactly.
const int FNV1_64_INIT = 0xcbf29ce484222325;
                         ^^^^^^^^^^^^^^^^^^
/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/fnv-1.0.1/lib/src/fnv_constants.dart:10:25: Error: The integer literal 0xffffffffffffffff can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript. In JavaScript 0x10000000000000000 is the nearest value that can be represented exactly.
const int UINT64_MASK = 0xffffffffffffffff;
                        ^^^^^^^^^^^^^^^^^^
Failed to compile application.
@hcanyz
Copy link
Author

hcanyz commented Aug 3, 2023

It seems that the web platform should use BigInt to calculate.

@Midi12
Copy link
Owner

Midi12 commented Aug 3, 2023

Yes, IIRC the compilation from Dart to JS doesn't handle 64 bit integers because the web target is only 32 bits or something like that. Unfortunately the primary goal of this library was to be a dependency for a console project.

If you want to contribute you're welcome to make a PR that enable the handling of both console and web targets.

@hcanyz hcanyz linked a pull request Aug 4, 2023 that will close this issue
@wjkoh
Copy link

wjkoh commented Jan 9, 2024

Glad to see that the web compatible version is coming up! I've written a Web-compatible Dart function to generate a 64-bit FNV-1a hash for my own uses. If anyone needs a quick, copy-and-paste solution for a web-compatible function, feel free to check out: https://gist.github.com/wjkoh/39d9a108f3e73bc728172492670bb97a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants