isar-community / isar

Extremely fast, easy to use, and fully async NoSQL database for Flutter
https://isar-community.dev
Apache License 2.0
133 stars 15 forks source link

So, because note_app depends on isar_generator ^3.1.0+1, version solving failed. #95

Closed mictadlo closed 1 month ago

mictadlo commented 1 month ago

Hi,

I failed to get isar database running with Flutter's pub version and the following code:

    import 'package:isar/isar.dart';

    part 'note.g.dart';

    @Collection()
    class Note {
      Id id = Isar.autoIncrement;
      late String text;
    }

Next, I ran:

    $ dart run build_runner build
    Building package executable... (9.0s)
    Built build_runner:build_runner.
    [INFO] Generating build script completed, took 508ms
    [INFO] Precompiling build script... completed, took 6.6s
    [INFO] Building new asset graph completed, took 1.7s
    [INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
    [WARNING] isar_generator on test/widget_test.dart:
    Your current `analyzer` version may not fully support your current SDK version.

    Analyzer language version: 3.1.0
    SDK language version: 3.4.0

    Please update to the latest `analyzer` version (6.8.0) by running
    `flutter packages upgrade`.

    If you are not getting the latest version by running the above command, you
    can try adding a constraint like the following to your pubspec to start
    diagnosing why you can't get the latest version:

    dev_dependencies:
      analyzer: ^6.8.0

    [INFO] Generating SDK summary completed, took 8.4s
    [INFO] Running build completed, took 10.2s
    [INFO] Caching finalized dependency graph completed, took 211ms
    [INFO] Succeeded after 10.4s with 6 outputs (33 actions)

When I tried to run the code, I encountered the following error:

    lib/models/note.g.dart:18:7: Error: The integer literal 6284318083599466921 can't be represented exactly in JavaScript.
    Try changing the literal to something that can be represented in JavaScript. In JavaScript 6284318083599466496 is the nearest value that can be represented exactly.
      id: 6284318083599466921,
          ^^^^^^^^^^^^^^^^^^^
    Failed to compile application.

I read about this project and I tried it:

$ dart pub add isar:^4.0.3 isar_flutter_libs:^4.0.3 --hosted-url=https://pub.isar-community.dev
"isar" is already in "dependencies". Will try to update the constraint.
"isar_flutter_libs" is already in "dependencies". Will try to update the constraint.
Because isar_generator >=3.1.0+1 depends on isar from hosted on https://pub.dev and note_app depends on isar from hosted on
  https://pub.isar-community.dev, isar_generator >=3.1.0+1 is forbidden.
So, because note_app depends on isar_generator ^3.1.0+1, version solving failed.

How to solve the issue?

Thank you in advance

nobkd commented 1 month ago

AFAIK isar v3 doesn't support web/js target. v4 should support it. You can also check the isar community fork, since the maintainer here seems to be inactive

You can also check out their v3 release, as it should have upgraded dependencies.

If you don't need web support, you probably have to disable it for that flutter project.

I don't think I can be of any further help, so good luck.

mictadlo commented 1 month ago

Thank you.

mrclauss commented 1 month ago

And if you want to use the v4 version, you need to remove isar_generator, that's what the error message is trying to say:

Because isar_generator >=3.1.0+1 depends on isar from hosted on https://pub.dev and note_app depends on isar from hosted on https://pub.isar-community.dev, isar_generator >=3.1.0+1 is forbidden.