Skip to content

Failed to compile for flutter web. int64MaxValue #30

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

Open
jessicamrbr opened this issue Apr 1, 2025 · 4 comments
Open

Failed to compile for flutter web. int64MaxValue #30

jessicamrbr opened this issue Apr 1, 2025 · 4 comments

Comments

@jessicamrbr
Copy link

Failed to compile for flutter web.

Error: The integer literal ... can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript. In JavaScript .... is the closest value that can be represented exactly.
const int int64MaxValue = ...;

@anidotnet
Copy link
Contributor

Could you please provide more context? A reproducible code may be?

@jessicamrbr
Copy link
Author

jessicamrbr commented Apr 1, 2025

https://dart.dev/resources/language/number-representation

Integer values no larger than 64 bits, depending on the platform. On native platforms, values can be from -263 to 263 - 1. On the web, integer values are represented as JavaScript numbers (64-bit floating-point values with no fractional part) and can be from -253 to 253 - 1.

...
late Nitrite _db;
late NitriteCollection _collection;
...
_db = await Nitrite.builder().openOrCreate();
_collection = await _db.getCollection("resources");
...
final doc = documentFromMap(data);
final res = await _collection.updateOne(doc, insertIfAbsent: true);
return doc.id.idValue;
...

flutter run -d chrome

@anidotnet
Copy link
Contributor

I have never tested it on web, I'll take a look and let you know.

@jessicamrbr
Copy link
Author

uhum...

the keys in indexeddb behind the hive db on the web should not work either, for the same reason.

Is ID with Snowflake too coupled? Or should it be easy to turn into a provider, to work with different ID mechanisms?

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

No branches or pull requests

2 participants