-
Notifications
You must be signed in to change notification settings - Fork 20
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
Disable web for isar versión 3.x #80
Comments
Same problem here! We've created an .exe that edits all the long numbers of the generated *.g.dart files before the program launches on the web, so it is compiling correctly on all platforms. However, this solution is horrible It would be super-awesome to have an Isar version 3.x that compiles on web! 🚀 (Even if it does not work there) |
I need to understand exactly the core of the problem. You have an app the compiles to web but you have another solution for local storage just for web. But still get problems because Isar is embedded to the app. Sounds correct? |
Exactly, our app is multiplatform. We use Isar for windows/mobile and we use SharedPreferences for web (some parts are disabled on web, so this solution fits us). 💬 It was working fine with version 3.0.0-dev.8 until we've updated the Flutter version (from 3.7.0 to 3.19.6). This new Flutter version was not compatible this Isar Version (because of the analyzer), so we had upgraded the version to Isar 3.1.6 In version 3.1.6, build_runner generates the .g.dart files with this kind of code: const BobSchema = CollectionSchema(
name: r'Bob',
id: 3446686616087529141, // <-- THIS LINE IS GENERATING TROUBLE
... Error: The integer literal 3446686616087529141 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript.
In JavaScript 3446686616087528960 is the nearest value that can be represented exactly. Replacing the id with a shorter number (15 digits max, for example), the project started compiling again in web. However, it is not working on other platforms then (because the id is not a valid Collection Schema Id). 🤕 For this reason, we've created a script that replaces the This is just a fix, but it would be fine that Isar compiles for web even if it does not work. So projects like ours would be working without patching it. Isar is an incredible database, so we want to use it in the future projects! 💯 |
Tks for the detailed response. Can you try this branch? At least I think it will run. (can't test it right now)
|
Thank you for your quick answer! 👏 I've tried this solution, but I'm getting some conflicts when I run the
My
Am I adding the dependencies correctly? |
Yes, but I think you should add to overrides too |
We had already tried it with the dependencies_override, but we got the same errors. |
Probably this will fix my issue too. I can't try because i've had the same issue as @festiburgos |
I'm getting the same error |
I don't get pubspec conflicts when I add all the packages to dependency_overrides
However, the ids in the generated files are still integers that are too large for javascript to handle, so the original issue persists. |
I created a fix that moves the generation of the id property (which is the reason for the web issues) from compile time to run time, that should fix the issue |
This seems to be one of the better workarounds to this issue for now. It's what I've done on my project too, at least until there's a proper fix for the problem. |
Can't it be merged with the v3 branch instead of dependency_overrides? |
Yes! Will work on it! |
My app is served on multiple platforms, but in web it crashes withe the famous: Error: The integer literal 489474... can't be represented exactly in JavaScript. We just need the isar to provide some services on mobile but it crashes in web despite we are not using isar in this platform.
It could be interesting to disable isar on web in some way to prevent the error.
The text was updated successfully, but these errors were encountered: