firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

πŸ› [Firestore ODM] CodeGen not building Collection Reference #11415

Closed Miamoto-Musashi closed 1 year ago

Miamoto-Musashi commented 1 year ago

Bug report

Describe the bug I'm trying to integrate Firestore ODM in a simple project but the codegen is not generating collection reference making this plug in useless

Steps to reproduce

Made a simple project to isolate the issue but could nt make it work

Steps to reproduce the behavior:

  1. Go to test project
  2. git clone to local folder
  3. flutter clean && flutter pub get && dart run build_runner watch --delete-conflicting-outputs
  4. See error on generated class file

Expected behavior

generated class file does not contains errors

Sample project

Odm_Test


Additional context

there is a message from me on the discussion telling more or less the same things


Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [βœ“] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F770820d darwin-x64, locale it-IT) [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [βœ“] Xcode - develop for iOS and macOS (Xcode 14.3.1) [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 2022.2) [βœ“] VS Code (version 1.80.2) [βœ“] Connected device (2 available) [βœ“] Network resources β€’ No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 3.0.5 Flutter SDK 3.10.5 odm_test 1.0.0+1 dependencies: - cloud_firestore 4.8.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_firestore_odm 1.0.0-dev.63 [cloud_firestore flutter json_annotation meta] - cupertino_icons 1.0.5 - firebase_auth 4.7.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.15.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_dynamic_links 5.3.4 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_storage 11.2.5 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - firebase_ui_firestore 1.5.5 [cloud_firestore firebase_ui_localizations flutter] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - json_annotation 4.8.1 [meta] dev dependencies: - build_runner 2.4.3 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - cloud_firestore_odm_generator 1.0.0-dev.63 [analyzer build build_config cloud_firestore_odm collection freezed_annotation graphs json_annotation meta recase source_gen] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - json_serializable 6.7.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] dependency overrides: - flutter_lints 2.0.2 [lints] - graphs 2.2.0 [collection] transitive dependencies: - _fe_analyzer_shared 61.0.0 [meta] - _flutterfire_internals 1.3.4 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 5.13.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.4.2 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.4.1 [analyzer async convert crypto glob logging meta package_config path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 4.0.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.2.1 [analyzer async build collection crypto graphs logging package_config path pool pub_semver stream_transform yaml] - build_runner_core 7.2.10 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta package_config path pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.6.1 [built_collection collection fixnum meta] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - clock 1.1.1 - cloud_firestore_platform_interface 5.15.3 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.6.3 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.5.0 [built_collection built_value collection matcher meta] - collection 1.17.1 - convert 3.1.1 [typed_data] - crypto 3.0.3 [typed_data] - dart_style 2.3.2 [analyzer args path pub_semver source_span] - fake_async 1.3.1 [clock collection] - file 7.0.0 [meta path] - firebase_auth_platform_interface 6.16.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.6.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.6.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_dynamic_links_platform_interface 0.2.6+4 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_storage_platform_interface 4.4.4 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.5 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - firebase_ui_localizations 1.5.0 [flutter flutter_localizations path] - fixnum 1.1.0 - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - freezed_annotation 2.4.1 [collection json_annotation meta] - frontend_server_client 3.2.0 [async path] - glob 2.1.2 [async collection file path string_scanner] - http 1.1.0 [async http_parser meta] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - intl 0.18.0 [clock meta path] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - lints 2.1.1 - logging 1.2.0 - matcher 0.12.15 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.2.0 - meta 1.9.1 - mime 1.0.4 - package_config 2.1.0 [path] - path 1.8.3 - plugin_platform_interface 2.1.5 [meta] - pool 1.5.1 [async stack_trace] - pub_semver 2.1.4 [collection meta] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - recase 4.1.0 - shelf 1.4.1 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.4.0 [analyzer async build dart_style glob path source_span yaml] - source_helper 1.3.4 [analyzer collection source_gen] - source_span 1.9.1 [collection path term_glyph] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - term_glyph 1.2.1 - test_api 0.5.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 1.0.1 [json_annotation] - typed_data 1.3.2 [collection] - vector_math 2.1.4 - watcher 1.1.0 [async path] - web_socket_channel 2.4.0 [async crypto stream_channel] - yaml 3.1.2 [collection source_span string_scanner] ```

danagbemava-nc commented 1 year ago

I can reproduce the issue using the code sample in the repo shared above. The workaround in https://github.com/firebase/flutterfire/issues/10956 doesn't seem to work anymore and even upgrading build_runner and odm dependencies to the latest version doesn't seem to solve the issue.

ngoctranfire commented 1 year ago

I'm also experiencing this issue as well too. Love to get some help on figuring out this issue btw!

mlab817 commented 1 year ago

It's been a while. I have just come across this issue while trying this package. Any working solutions?

yelkamel commented 1 year ago

I have the same problem... πŸ₯²

danagbemava-nc commented 1 year ago

cc @rrousselGit

rrousselGit commented 1 year ago

You are not allowed to put the annotation on properties of objects. The annotation must be on a "global" element (be it a class or a global variable). Anything else is not detected.

So that is expected

tabarnouche commented 1 year ago

I'll share my case for someone stuck in the same situation as mine.

I had 3 causes.

  1. First I didn't have cloud_firestore_odm_generator in pubspec.yaml. So I added it with flutter pub add cloud_firestore_odm_generator.
  2. Secondly, the added version from the command above was ^1.0.0-dev.58, which causes the graphs dependency problem as mentioned in https://github.com/firebase/flutterfire/issues/10956#issuecomment-1557496758. So I changed it to ^1.0.0-dev.73 the latest version as of now.
  3. Finally I had riverpod_lint in pubspec.yaml. I don't know why but riverpod_lint and cloud_firestore_odm_generator seem to have a conflict. So I just cut riverpod_lint off from pubspec.yaml.

Hope this helps.