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.74k stars 3.98k forks source link

🐛 [cloud_firestore_odm_generator] odm code generation is badly broken #10977

Closed ewankirk closed 1 year ago

ewankirk commented 1 year ago

Bug report

Code Generation is broken. Only creates the FromJson and ToJson functions.

cloud_firestore_odm_generator: ^1.0.0-dev.58 Flutter: 3.10.0

Steps to reproduce

Steps to reproduce the behavior:

  1. Run dart run build_runner build --delete-conflicting-outputs on a model defining file.
  2. For example:
    
    import 'package:cloud_firestore/cloud_firestore.dart';
    import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';

import '../constants/app_constants.dart';

part 'card_info.g.dart';

@Collection('cardinfo') final cardInfoRef = CardInfoCollectionReference();

@firestoreSerializable class CardInfo { @Id() final String id; String name; String cardFrontAvatarUrl; int accessCounter;

CardInfo({ required this.id, required this.name, this.accessCounter = 0, this.cardFrontAvatarUrl = '', }); }

4. The complete code produced is
```dart
// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'card_info.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

CardInfo _$CardInfoFromJson(Map<String, dynamic> json) => CardInfo(
      id: json['id'] as String,
      name: json['name'] as String,
      accessCounter: json['accessCounter'] as int? ?? 0,
      cardFrontAvatarUrl: json['cardFrontAvatarUrl'] as String? ?? '',
    );

const _$CardInfoFieldMap = <String, String>{
  'id': 'id',
  'name': 'name',
  'cardFrontAvatarUrl': 'cardFrontAvatarUrl',
  'accessCounter': 'accessCounter',
};

Map<String, dynamic> _$CardInfoToJson(CardInfo instance) => <String, dynamic>{
      'id': instance.id,
      'name': instance.name,
      'cardFrontAvatarUrl': instance.cardFrontAvatarUrl,
      'accessCounter': instance.accessCounter,
    };

which doesn't include the collection reference or any of the query functions.

Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.78.2) [✓] Connected device (4 available) ! Error: (null) needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1) [✓] Network resources • No issues found! ```

Flutter dependencies

Click To Expand ``` Dart SDK 3.0.0 Flutter SDK 3.10.0 cardzap 1.3.1+1 dependencies: - app_tracking_transparency 2.0.4 [flutter] - camera 0.10.5 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle quiver] - carousel_slider 4.2.1 [flutter] - cloud_firestore 4.7.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_firestore_odm 1.0.0-dev.58 [cloud_firestore flutter json_annotation meta] - connectivity_plus 4.0.0 [flutter flutter_web_plugins connectivity_plus_platform_interface js meta nm] - country_picker 2.0.20 [collection flutter] - cross_file 0.3.3+4 [js meta] - dart_countries 3.0.3 - dotted_border 2.0.0+3 [flutter path_drawing] - dropdown_search 5.0.6 [flutter] - encrypt 5.0.1 [args asn1lib clock collection crypto pointycastle] - equatable 2.0.5 [collection meta] - firebase_analytics 10.4.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.6.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.12.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.0 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 5.3.0 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_performance 0.9.2 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - firebase_remote_config 4.2.0 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - firebase_storage 11.2.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_bloc 8.1.2 [flutter bloc provider] - flutter_colorpicker 1.0.3 [flutter] - flutter_contacts 1.1.6 [flutter] - flutter_jailbreak_detection 1.10.0 [flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_platform_widgets 3.3.2 [flutter cupertino_icons] - flutter_svg 2.0.5 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - fluttertoast 8.2.1 [flutter flutter_web_plugins] - gallery_saver 2.3.2 [flutter path_provider http path] - geocoder2 1.4.0 [flutter http] - geolocator 9.0.2 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows] - google_fonts 4.0.4 [flutter http path_provider crypto] - google_maps_flutter 2.2.6 [flutter google_maps_flutter_android google_maps_flutter_ios google_maps_flutter_platform_interface] - google_mlkit_entity_extraction 0.7.0 [flutter google_mlkit_commons] - google_mlkit_text_recognition 0.6.0 [flutter google_mlkit_commons] - google_sign_in 6.1.0 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - hive 2.2.3 [meta crypto] - hive_flutter 1.1.0 [flutter hive path_provider path] - http 0.13.6 [async http_parser meta] - image 4.0.17 [archive meta xml] - image_cropper 4.0.1 [flutter image_cropper_platform_interface image_cropper_for_web] - image_picker 0.8.7+5 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - in_app_review 2.0.6 [flutter in_app_review_platform_interface] - intl 0.18.0 [clock meta path] - json_annotation 4.8.1 [meta] - ndef 0.3.1 [uuid] - nfc_manager 3.2.0 [flutter] - package_info_plus 4.0.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path_provider 2.0.15 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - permission_handler 10.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - phone_numbers_parser 7.0.2 [phone_number_metadata meta dart_countries] - qr_code_scanner 1.0.1 [js flutter flutter_web_plugins] - qr_flutter 4.1.0 [flutter qr] - quick_actions 1.0.3 [flutter quick_actions_android quick_actions_ios quick_actions_platform_interface] - screenshot 2.1.0 [flutter] - share_plus 7.0.0 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - sign_in_with_apple 4.3.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - sizer 2.0.15 [universal_io flutter] - sn_progress_dialog 1.1.3 [flutter] - url_launcher 6.1.11 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - build_runner 2.4.4 [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.58 [analyzer build build_config cloud_firestore_odm collection freezed_annotation json_annotation meta recase source_gen] - flutter_lints 2.0.1 [lints] - json_serializable 6.6.2 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] transitive dependencies: - _fe_analyzer_shared 60.0.0 [meta] - _flutterfire_internals 1.3.0 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 5.12.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 3.3.7 [crypto path pointycastle] - args 2.4.1 - asn1lib 1.4.0 - async 2.11.0 [collection meta] - bloc 8.1.1 [meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.4.0 [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.0 [analyzer async build collection crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.8 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.5.0 [built_collection collection fixnum meta] - camera_android 0.10.8 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform] - camera_avfoundation 0.9.13+1 [camera_platform_interface flutter stream_transform] - camera_platform_interface 2.5.0 [cross_file flutter plugin_platform_interface stream_transform] - camera_web 0.3.1+3 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - clock 1.1.1 - cloud_firestore_platform_interface 5.14.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.5.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.4.0 [built_collection built_value collection matcher meta] - collection 1.17.1 - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - convert 3.1.1 [typed_data] - crypto 3.0.3 [typed_data] - cupertino_icons 1.0.5 - dart_style 2.3.1 [analyzer args path pub_semver source_span] - dbus 0.7.8 [args ffi meta xml] - fake_async 1.3.1 [clock collection] - ffi 2.0.2 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.6.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.4 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.15.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.5.0 [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.5.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.6 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_performance_platform_interface 0.1.4 [_flutterfire_internals firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.4 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - firebase_remote_config_platform_interface 1.4.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.4.0 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - firebase_storage_platform_interface 4.4.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.0 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.1.0 - flutter_plugin_android_lifecycle 2.0.14 [flutter] - 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] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - freezed_annotation 2.2.0 [collection json_annotation meta] - frontend_server_client 3.2.0 [async path] - geolocator_android 4.1.8 [flutter geolocator_platform_interface] - geolocator_apple 2.2.5 [flutter geolocator_platform_interface] - geolocator_platform_interface 4.0.7 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.1.6 [flutter flutter_web_plugins geolocator_platform_interface] - geolocator_windows 0.1.1 [flutter geolocator_platform_interface] - glob 2.1.1 [async collection file path string_scanner] - google_identity_services_web 0.2.1 [js meta] - google_maps_flutter_android 2.4.14 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface stream_transform] - google_maps_flutter_ios 2.2.1 [flutter google_maps_flutter_platform_interface stream_transform] - google_maps_flutter_platform_interface 2.2.6 [collection flutter plugin_platform_interface stream_transform] - google_mlkit_commons 0.3.0 [flutter] - google_sign_in_android 6.1.14 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.6.2 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.0 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.12.0 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http js] - graphs 2.3.0 [collection] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image_cropper_for_web 2.0.0 [flutter flutter_web_plugins image_cropper_platform_interface js] - image_cropper_platform_interface 4.0.0 [flutter plugin_platform_interface http] - image_picker_android 0.8.6+14 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.12 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.7+4 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.3 [cross_file flutter http plugin_platform_interface] - in_app_review_platform_interface 2.0.4 [flutter url_launcher plugin_platform_interface platform] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - lints 2.1.0 - logging 1.1.1 - 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 - nested 1.0.0 [flutter] - nm 0.5.0 [dbus] - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.3 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.0.27 [flutter path_provider_platform_interface] - path_provider_foundation 2.2.3 [flutter path_provider_platform_interface] - path_provider_linux 2.1.10 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.6 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 10.2.1 [flutter permission_handler_platform_interface] - permission_handler_apple 9.0.8 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.9.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.2 [flutter permission_handler_platform_interface] - petitparser 5.4.0 [meta] - phone_number_metadata 5.0.4 [path dart_countries] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - pointycastle 3.7.3 [collection convert js] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - provider 6.0.5 [collection flutter nested] - pub_semver 2.1.4 [collection meta] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - qr 3.0.1 [meta] - quick_actions_android 1.0.5 [flutter quick_actions_platform_interface] - quick_actions_ios 1.0.5 [flutter quick_actions_platform_interface] - quick_actions_platform_interface 1.0.4 [flutter plugin_platform_interface] - quiver 3.2.1 [matcher] - recase 4.1.0 - share_plus_platform_interface 3.2.1 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - 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] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js] - sky_engine 0.0.99 - source_gen 1.3.2 [analyzer async build dart_style glob path source_span yaml] - source_helper 1.3.3 [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] - universal_io 2.2.0 [collection meta typed_data] - url_launcher_android 6.0.33 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.4 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.16 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.6 [flutter url_launcher_platform_interface] - uuid 3.0.7 [crypto] - vector_graphics 1.1.5+1 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.5+1 - vector_graphics_compiler 1.1.5+1 [args meta path_parsing xml vector_graphics_codec] - vector_math 2.1.4 - watcher 1.1.0 [async path] - web_socket_channel 2.4.0 [async crypto stream_channel] - win32 4.1.4 [ffi] - xdg_directories 1.0.0 [meta path process] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

darshankawar commented 1 year ago

@ewankirk I believe you are hitting https://github.com/firebase/flutterfire/issues/10956 so please follow-up in it that has solution mentioned and see if it helps in your case. Closing from here as a duplicate.

ewankirk commented 1 year ago

Thank you very much. I didn't manage to find #10956 which was my bad.