objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
927 stars 115 forks source link

plz adapter dart 2.10.1 and flutter 1.22.1 #124

Closed tenon-du closed 3 years ago

tenon-du commented 3 years ago

my environment

Flutter is already up to date on channel stable
Flutter 1.22.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f30b7f4db9 (3 days ago) • 2020-10-08 10:06:30 -0700
Engine • revision 75bef9f6c8
Tools • Dart 2.10.1

the following error occurred when i use flutter packages pub run build_runner build --delete-conflicting-outputs.

[INFO] Generating build script... [INFO] Generating build script completed, took 484ms

[WARNING] Deleted previous snapshot due to missing asset graph. [INFO] Creating build script snapshot...... [INFO] Creating build script snapshot... completed, took 17.0s

[INFO] Initializing inputs [INFO] Building new asset graph... [INFO] Building new asset graph completed, took 1.6s

[INFO] Checking for unexpected pre-existing outputs.... [INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build... [WARNING] objectbox_generator:resolver on package:objectbox_generator/objectbox_generator.dart: Your current analyzer version may not fully support your current SDK version.

Please try upgrading to the latest analyzer by running flutter packages upgrade.

Analyzer language version: 2.9.0 SDK language version: 2.10.0

If you are getting this message and have the latest analyzer please file an issue at https://github.com/dart-lang/sdk/issues/new with the title "No published analyzer available for language version 2.10.0". Please search the issue tracker first and thumbs up and/or subscribe to existing issues if present to avoid duplicates.

[INFO] Generating SDK summary... [SEVERE] objectbox_generator:resolver on package:objectbox_generator/objectbox_generator.dart:

Bad state: Unexpected diagnostics: /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:152:17 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:119:41 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:133:32 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:186:51 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:88:62 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:153:38 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:64:4 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:154:25 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:17 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:118:48 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:37 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:19:11 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:159:38 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:168:32 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:47:14 - This requires the 'non-nullable' language feature to be enabled. [SEVERE] objectbox_generator:resolver on package:objectbox_generator/objectbox_generator.dart:

Bad state: Unexpected diagnostics: /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:152:17 - This requires the 'non-nullable' language feature to be enabled. /Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:119:

greenrobot-team commented 3 years ago

The error above is

[SEVERE] objectbox_generator:resolver on package:objectbox_generator/objectbox_generator.dart:

Bad state: Unexpected diagnostics:
/Users/dugang/Library/Android/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:152:17 - This requires the 'non-nullable' language feature to be enabled.

How is this related to ObjectBox for Flutter?

greenrobot commented 3 years ago

@DuJerry Do you get the same output with ObjectBox 0.8.0?

softkot commented 3 years ago

Also unable to generate objectbox after upgrading to flutter 1.22.1 and got the same error for flutter packages pub run build_runner build --delete-conflicting-outputs

greenrobot-team commented 3 years ago

@softkot Did you also try with the recently released ObjectBox Dart 0.8.0?

softkot commented 3 years ago

@softkot Did you also try with the recently released ObjectBox Dart 0.8.0?

Yes i did it with 0.8.0

softkot commented 3 years ago

I found it works if use build_runner: 1.10.2

greenrobot-team commented 3 years ago

@softkot So what build_runner version, that did not work, were you using?

softkot commented 3 years ago

1.10.1 does not work

greenrobot-team commented 3 years ago

1.10.1 does not work

That makes sense. According to their changelog this version pins analyzer to 0.39.14. https://pub.dev/packages/build_runner/changelog

tenon-du commented 3 years ago

Flutter (Channel stable, 1.22.2, on Mac OS X 10.15.7 19H2, locale zh-Hans-CN) • Flutter version 1.22.2 at /Users/dugang/Library/Android/flutter • Framework revision 84f3d28555 (5 days ago), 2020-10-15 16:26:19 -0700 • Engine revision b8752bbfff • Dart version 2.10.2 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn

dependencies:
  json_annotation: ^3.1.0
  objectbox: ^0.8.0
  objectbox_flutter_libs: ^0.8.0

dev_dependencies:
  build_runner: ^1.10.3
  json_serializable: ^3.5.0
  objectbox_generator: ^0.8.0

flutter packages pub run build_runner build generate success

[INFO] Generating build script... [INFO] Generating build script completed, took 567ms

[INFO] Initializing inputs [INFO] Reading cached asset graph... [INFO] Reading cached asset graph completed, took 168ms

[INFO] Checking for updates since last build... [INFO] Checking for updates since last build completed, took 1.5s

[INFO] Running build... [INFO] 2.2s elapsed, 0/1 actions completed. [INFO] objectbox_generator:resolver on lib/model/entity/test.dart:entity Test(0:0) [INFO] objectbox_generator:resolver on lib/model/entity/test.dart: property id(0:0) type:6 flags:1 [INFO] objectbox_generator:generator on lib/$lib$:Package: ess [INFO] objectbox_generator:generator on lib/$lib$:Found 1 entities in: (lib/model/entity/test.objectbox.info) [INFO] objectbox_generator:generator on lib/$lib$:Using model: lib/objectbox-model.json [INFO] objectbox_generator:generator on lib/$lib$:Generating code: lib/objectbox.g.dart [INFO] Running build completed, took 2.4s

[INFO] Caching finalized dependency graph... [INFO] Caching finalized dependency graph completed, took 90ms

[INFO] Succeeded after 2.5s with 4 outputs (5 actions)

vaind commented 3 years ago

@DuJerry please try running pub upgrade and see if that helps you get the fixed dependencies.

For context, this has been caused by https://github.com/dart-lang/build/issues/2763 and as has been said above, seems only to be resolvable by also requiring a fairly recent minimum dart SDK version (v2.10) enforced by the fixed build_runner v1.10.2

greenrobot-team commented 3 years ago

@DuJerry Thanks for verifying using build_runner ^1.10.3 works as well!

So TL;DR for anyone coming here: use at least build_runner 1.10.2, even better 1.10.3.

dvilcode commented 3 years ago

1.10.2

It works! Thanks

vaind commented 3 years ago

Not sure if we can do anything on our side without raising min-SDK constraint so I'm closing the issue.

Feel free to follow up if you have any change suggestions.